def getEntityEntity(sympyEntity): """ convert sympy object into PyCAD object """ if isinstance(sympyEntity, geoSympy.Circle): arg={"ARC_0":Point(0.0, 0.0), "ARC_1":1, "ARC_2":None, "ARC_3":None } arc=Arc(arg) arc.setFromSympy(sympyEntity) return arc elif isinstance(sympyEntity, geoSympy.Point): p=Point(0.0, 0.0) p.setFromSympy(sympyEntity) return p elif isinstance(sympyEntity, geoSympy.Segment): segArg={"SEGMENT_0":Point(0.0, 0.0), "SEGMENT_1":Point(1.0, 1.0)} seg=Segment(segArg) seg.setFromSympy(sympyEntity) return seg elif isinstance(sympyEntity, geoSympy.Ellipse): arg={"ELLIPSE_0":Point(0.0, 0.0), "ELLIPSE_1":1.0, "ELLIPSE_2":2.0} e=Ellipse(arg) e.setFromSympy(sympyEntity) return e else: raise "not supported entity"
def getEntityEntity(sympyEntity): """ convert sympy object into PyCAD object """ if isinstance(sympyEntity, geoSympy.Circle): arg = { "ARC_0": Point(0.0, 0.0), "ARC_1": 1, "ARC_2": None, "ARC_3": None } arc = Arc(arg) arc.setFromSympy(sympyEntity) return arc elif isinstance(sympyEntity, geoSympy.Point): p = Point(0.0, 0.0) p.setFromSympy(sympyEntity) return p elif isinstance(sympyEntity, geoSympy.Segment): segArg = {"SEGMENT_0": Point(0.0, 0.0), "SEGMENT_1": Point(1.0, 1.0)} seg = Segment(segArg) seg.setFromSympy(sympyEntity) return seg elif isinstance(sympyEntity, geoSympy.Ellipse): arg = { "ELLIPSE_0": Point(0.0, 0.0), "ELLIPSE_1": 1.0, "ELLIPSE_2": 2.0 } e = Ellipse(arg) e.setFromSympy(sympyEntity) return e else: raise "not supported entity"
def testSympyCircle(): print "++ Sympy Arc ++" p1 = Point(0, 1) arg = {"ARC_0": p1, "ARC_1": 5, "ARC_2": 0, "ARC_3": 6.2831} arc = Arc(arg) sympCircle = arc.getSympy() print "sympCircle", sympCircle sympCircel = geoSympy.Circle(geoSympy.Point(10, 10), 10) arc.setFromSympy(sympCircel) print "Pythonca Arc ", arc print "-- Sympy Arc --"
def testSympyCircle(): print "++ Sympy Arc ++" p1=Point(0, 1) arg={"ARC_0":p1, "ARC_1":5, "ARC_2":0, "ARC_3":6.2831} arc=Arc(arg) sympCircle=arc.getSympy() print "sympCircle", sympCircle sympCircel=geoSympy.Circle(geoSympy.Point(10, 10), 10) arc.setFromSympy(sympCircel) print "Pythonca Arc ", arc print "-- Sympy Arc --"
def segment_circle(): print "++ segment_circle ++" p1 = Point(0, 0) arg = {"ARC_0": p1, "ARC_1": 5, "ARC_2": 0, "ARC_3": 6.2831} arc = Arc(arg) p2 = Point(0, 0) p3 = Point(-1, 0) arg = {"CLINE_0": p2, "CLINE_1": p3} seg1 = CLine(arg) print find_intersections(arc, seg1) print "-- segment_circle --"
def applyCommand(self): if len(self.value)<2: raise PyCadWrongImputData("Wrong number of imput parameter") self.applyDefault() arg={"ARC_0":self.value[0], "ARC_1":self.value[1], "ARC_2":self.value[2], "ARC_3":self.value[3] } arc=Arc(arg) self.document.saveEntity(arc)
def createArc(self, x, y, r, color=None, sa=None, ea=None): """ Create a Arc entitys into the current drawing """ _center = Point(x, y) if sa is None or ea is None: sa = ea = 0 #This is the case of circle else: sa = (sa * math.pi) / 180 ea = (ea * math.pi) / 180 ea = ea - sa args = {"ARC_0": _center, "ARC_1": r, "ARC_2": sa, "ARC_3": ea} _arc = Arc(args) self.__kernel.saveEntity(_arc)