ADD_UNIT_TESTS(
TestModeler.py
TestSketcherAddLine.py
+ TestSketcherAddCircle.py
TestSketcherSetCoincident.py
+ TestSketcherSetParallel.py
)
--- /dev/null
+import unittest
+import modeler
+from TestSketcher import SketcherTestCase
+
+class SketcherAddCircle(SketcherTestCase):
+ def runTest(self):
+ circle = self.sketch.addCircle(0, 10, 20)
+ self.assertEqual(circle.centerData().x(), 0.0)
+ self.assertEqual(circle.centerData().y(), 10.0)
+ self.assertEqual(circle.radiusData().value(), 20.0)
+
+
+if __name__ == "__main__":
+ unittest.main()
\ No newline at end of file
import modeler
from TestSketcher import SketcherTestCase
-class SketcherAddLineTestCase(SketcherTestCase):
+class SketcherAddLine(SketcherTestCase):
def runTest(self):
line = self.sketch.addLine(0, 0, 0, 1)
self.assertEqual(line.startPointData().x(), line.endPointData().x())
--- /dev/null
+import unittest
+import modeler
+from TestSketcher import SketcherTestCase
+
+class SketcherSetParallel(SketcherTestCase):
+ def runTest(self):
+ l1 = self.sketch.addLine(0, 0, 0, 1)
+ l2 = self.sketch.addLine(0, 1, 1, 1)
+ self.sketch.setParallel(l1.result(), l2.result())
+
+if __name__ == "__main__":
+ unittest.main()
\ No newline at end of file
+"""Sketch circle feature interface."""
+
from GeomDataAPI import geomDataAPI_Point2D
-class Circle():
+def addCircle(sketch, x, y, r):
+ feature = sketch.addFeature("SketchCircle")
+ return CircleInterface(feature, x, y, r)
- def __init__(self, sketch, x, y, r):
- self.my = sketch.addFeature("SketchCircle")
- geomDataAPI_Point2D( self.my.data().attribute("CircleCenter") ).setValue(x, y)
- self.my.data().real("CircleRadius").setValue(r)
- self.my.execute()
+class CircleInterface():
+ 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 centerData (self):
- return geomDataAPI_Point2D( self.my.data().attribute("CircleCenter") )
+ def centerData (self):
+ return self._center
+
+ def radiusData (self):
+ return self._radius
- def result (self):
- return self.my.lastResult() # Returns the circular line attribute
+ def result (self):
+ return self._feature.lastResult() # Returns the circular line attribute
from GeomAlgoAPI import *
import modeler.sketcher.point as sk_point
import modeler.sketcher.line as sk_line
-from modeler.sketcher.circle import Circle
+import modeler.sketcher.circle as sk_circle
def addSketch(doc, plane):
"""Add a Sketch feature to the Part or PartSet and return an interface
def addCircle (self, *args):
"""Adds a circle to this Sketch."""
- return Circle(self._feature, *args)
+ circle_interface = sk_circle.addCircle(self._feature, *args)
+ return circle_interface
# Creation of Geometrical and Dimensional Constraints