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 testSympyEllipse(): print "++ Sympy Ellipse ++" p1 = Point(0, 1) arg = {"ELLIPSE_0": p1, "ELLIPSE_1": 100, "ELLIPSE_2": 50} eli = Ellipse(arg) sympEli = eli.getSympy() print "sympEllipse", sympEli sympEli1 = geoSympy.Ellipse(geoSympy.Point(10, 10), 300, 200) eli.setFromSympy(sympEli1) print "Pythonca Ellipse ", eli print "-- Sympy Ellipse --"
def testSympyEllipse(): print "++ Sympy Ellipse ++" p1=Point(0, 1) arg={"ELLIPSE_0":p1, "ELLIPSE_1":100, "ELLIPSE_2":50} eli=Ellipse(arg) sympEli=eli.getSympy() print "sympEllipse", sympEli sympEli1=geoSympy.Ellipse(geoSympy.Point(10, 10), 300, 200) eli.setFromSympy(sympEli1) print "Pythonca Ellipse ", eli print "-- Sympy Ellipse --"
def applyCommand(self): if len(self.value) > 3: raise PyCadWrongInputData("Wrong number of input parameter") arg = { "ELLIPSE_0": self.value[0], "ELLIPSE_1": self.value[1], "ELLIPSE_2": self.value[2] } ellipse = Ellipse(arg) self.document.saveEntity(ellipse)
def segment_ellipse(): print "++ segment_ellipse ++" p1 = Point(0, 0) arg = {"ELLIPSE_0": p1, "ELLIPSE_1": 300, "ELLIPSE_2": 100} eli = Ellipse(arg) p2 = Point(0, 0) p3 = Point(-1, 0) arg = {"CLINE_0": p2, "CLINE_1": p3} seg1 = CLine(arg) print find_intersections(eli, seg1) print "-- segment_ellipse --"