--- /dev/null
- def centerData (self):
+ """Sketch circle feature interface."""
+
+ from GeomDataAPI import geomDataAPI_Point2D
+ from model.errors import WrongNumberOfArguments
+
+ class Arc():
++ """Interface for editing a sketch arc feature."""
+ def __init__(self, arc_feature, *args):
+ self._feature = arc_feature
+ self._center = geomDataAPI_Point2D(
+ self._feature.data().attribute("ArcCenter")
+ )
+ self._start_point = geomDataAPI_Point2D(
+ self._feature.data().attribute("ArcStartPoint")
+ )
+ self._end_point = geomDataAPI_Point2D(
+ self._feature.data().attribute("ArcEndPoint")
+ )
+ if len(args) == 6:
+ self.__createByCoordinates(*args)
+ elif len(args) == 3:
+ self.__createByPoints(*args)
+ else:
+ raise WrongNumberOfArguments(
+ "Arc takes 3 or 6 arguments (%s given)" % len(args)
+ )
+
- def startPointData (self):
++ def centerData(self):
++ """Return the center point data."""
+ return self._center
+
- def endPointData (self):
++ def startPointData(self):
++ """Return the start point data."""
+ return self._start_point
+
- def result (self):
++ def endPointData(self):
++ """Return the end point data."""
+ return self._end_point
+
- def __createByCoordinates(self,
- center_x, center_y,
- start_x, start_y,
- end_x, end_y):
++ def result(self):
++ """Return the arc circular line attribute."""
+ return self._feature.lastResult()
+
+ ########
+ #
+ # Private methods
+ #
+ ########
+
++ def __createByCoordinates(self, center_x, center_y,
++ start_x, start_y,
++ end_x, end_y):
+ """Create an arc by point coordinates."""
+ self._center.setValue(center_x, center_y)
+ self._start_point.setValue(start_x, start_y)
+ self._end_point.setValue(end_x, end_y)
+ self._feature.execute()
+
+ def __createByPoints(self, center, start, end):
+ """Create an arc with point objects."""
+ self._center.setValue(center.x(), center.y())
+ self._start_point.setValue(start.x(), start.y())
+ self._end_point.setValue(end.x(), end.y())
+ self._feature.execute()
+
+
+
+
+
--- /dev/null
- def centerData (self):
+ """Sketch circle feature interface."""
+
+ from GeomDataAPI import geomDataAPI_Point2D
+
+ class Circle():
++ """Interface for circle feature data manipulation."""
++
+ def __init__(self, circle_feature, x, y, r):
+ self._feature = circle_feature
+ self._center = geomDataAPI_Point2D(
+ self._feature.data().attribute("CircleCenter")
+ )
+ self._radius = self._feature.data().real("CircleRadius")
+ self._center.setValue(x, y)
+ self._radius.setValue(r)
+ self._feature.execute()
+
-
- def radiusData (self):
++ def centerData(self):
++ """Return center data."""
+ return self._center
- def result (self):
- return self._feature.lastResult() # Returns the circular line attribute
++
++ def radiusData(self):
++ """Return radius data."""
+ return self._radius
+
++ def result(self):
++ """Return the cicular line attribute."""
++ return self._feature.lastResult()
--- /dev/null
- rigid.refattr("ConstraintEntityA").setObject( self._feature.firstResult() )
+ from GeomDataAPI import geomDataAPI_Point2D
+
+ class Line():
+ """Interface for editing of a sketch line feature."""
+ def __init__(self, line_feature, *args):
+ self._feature = line_feature
+ self._start_point = geomDataAPI_Point2D(
+ self._feature.data().attribute("StartPoint")
+ )
+ self._end_point = geomDataAPI_Point2D(
+ self._feature.data().attribute("EndPoint")
+ )
+ if len(args) == 4:
+ self.__createByCoordinates(*args)
+ elif len(args) == 2:
+ self.__createByPoints(*args)
+ elif len(args) == 1:
+ self.__createByName(sketch, *args)
+ else:
+ raise Exception("cannot create the Line")
+
+ def __createByCoordinates(self, x1, y1, x2, y2):
+ self._start_point.setValue(x1, y1)
+ self._end_point.setValue(x2, y2)
+ self._feature.execute()
+
+ def __createByPoints(self, p1, p2):
+ self._start_point.setValue(p1.x(), p1.y())
+ self._end_point.setValue(p2.x(), p2.y())
+ self._feature.execute()
+
+ def __createByName(self, sketch, name):
+ self._feature.data().selection("External").selectSubShape("EDGE", name)
+ self._feature.execute()
+ rigid = sketch.addFeature("SketchConstraintRigid")
- def startPointData (self):
++ rigid.refattr("ConstraintEntityA").setObject(self._feature.firstResult())
+
- def endPointData (self):
++ def startPointData(self):
+ return self._start_point
+
- def result (self):
++ def endPointData(self):
+ return self._end_point
+
++ def result(self):
+ return self._feature.firstResult()