SketchPlugin_ConstraintPerpendicular
static const std::string MY_CONSTRAINT_PERPENDICULAR_ID("SketchConstraintPerpendicular");
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::type());
- data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::type());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId());
+ data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId());
"""
from GeomDataAPI import *
from ModelAPI import *
+from salome.shaper import model
+
#=========================================================================
# Initialization of the test
#=========================================================================
#=========================================================================
aSession.startOperation()
aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = modelAPI_CompositeFeature(aSketchCommonFeature)
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
origin.setValue(0, 0, 0)
dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
dirx.setValue(1, 0, 0)
-diry = geomDataAPI_Dir(aSketchFeature.attribute("DirY"))
-diry.setValue(0, 1, 0)
norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
norm.setValue(0, 0, 1)
aSession.finishOperation()
aLineBStartPoint.setValue(25., 40.)
aLineBEndPoint.setValue(25., 125.)
aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 8)
#=========================================================================
# Make a constraint to keep the length of the line constant
# to prevent perpendicular constraint collapsing line to point
assert (aLineBStartPoint.y() == 40)
assert (aLineBEndPoint.x() == 25)
assert (aLineBEndPoint.y() == 125)
+assert (model.dof(aSketchFeature) == 6)
#=========================================================================
# Link lines with perpendicular constraint
#=========================================================================
refattrB.setObject(aResultB)
aPerpendicularConstraint.execute()
aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 5)
#=========================================================================
# Check values and move one constrainted object
#=========================================================================
aSession.finishOperation()
assert (aLineBStartPointPrev != (aLineBStartPoint.x(), aLineBStartPoint.y()))
assert (aLineBEndPointPrev != (aLineBEndPoint.x(), aLineBEndPoint.y()))
+assert (model.dof(aSketchFeature) == 5)
#=========================================================================
# End of test
#=========================================================================
+
+assert(model.checkPythonDump())