def CreateModifieEntity(kr): """ test for create and modifie an entity """ ent = createSegment(kr) celement = {'POINT_1': Point(100, 100), 'POINT_2': Point(200, 200)} ent.setConstructionElement(celement) kr.saveEntity(ent)
def testSingleSegment(kernel): """ create a single segment """ _p1 = Point(10, 10) _p2 = Point(10, 20) _s = Segment(_p1, _p2) kernel.saveEntity(_s)
def newSegment(self): """ create a new segment """ try: val = (raw_input("-->Get First Point x,y :")) p1 = Point(val[0], val[1]) val = (raw_input("-->Get Second Point x,y :")) p2 = Point(val[0], val[1]) _s = Segment(p1, p2) self.__kr.saveEntity(_s) except: print "---->Error on point creation !!"
def testMultiSegments(kernel, nSegments): """ create a single segment """ startTime = time.clock() kernel.startMassiveCreation() for i in range(nSegments): _p1 = Point(10, i) _p2 = Point(10, i) _s = Segment(_p1, _p2) kernel.saveEntity(_s) kernel.performCommit() endTime = time.clock() - startTime print "Create n: %s entity in : %ss" % (str(nSegments), str(endTime))
def getRandomPoint(self): """ get e random point """ x = random() * 1000 y = random() * 1000 return Point(x, y)
def testGeoChamfer(self): self.outputMsg("Test Chamfer") p1 = Point(0.0, 0.0) p2 = Point(10.0, 0.0) p3 = Point(0.0, 10.0) s1 = Segment(p1, p2) s2 = Segment(p1, p3) cmf = Chamfer(s1, s2, 2.0, 2.0) cl = cmf.getLength() self.outputMsg("Chamfer Lengh %s" % str(cl)) s1, s2, s3 = cmf.getReletedComponent() if s3: for p in s3.getEndpoints(): x, y = p.getCoords() self.outputMsg("P1 Cords %s,%s" % (str(x), str(y))) else: self.outputMsg("Chamfer segment in None")
def testSinglePoint(kernel): """ test single point operation """ startTime = time.clock() print "Create a single point" basePoint = Point(10, 1) print "singlePoint ", type(basePoint) kernel.saveEntity(basePoint) endTime = time.clock() - startTime print "Time for saving a single point %ss" % str(endTime)
def imputPoint(self, msg): """ ask at the user to imput a point """ msg = msg + " x,y " value = self.inputMsg(msg) if value: coords = value.split(',') x = float(coords[0]) y = float(coords[1]) return Point(x, y) return None
def testMultiPoints(kernel, nPoint): """ test the point operatoin """ startTime = time.clock() kernel.startMassiveCreation() for i in range(nPoint): basePoint = Point(10, i) kernel.saveEntity(basePoint) kernel.performCommit() endTime = time.clock() - startTime print "Create n: %s entity in : %ss" % (str(nPoint), str(endTime))
def testChamferCommand(self): """ this function is usefoul for short test as soon it works copy the code into featureTest """ newDoc = self.__pyCadApplication.newDocument() intPoint = Point(0.0, 0.0) s1 = Segment(intPoint, Point(10.0, 0.0)) s2 = Segment(intPoint, Point(0.0, 10.0)) ent1 = newDoc.saveEntity(s1) ent2 = newDoc.saveEntity(s2) cObject = self.__pyCadApplication.getCommand("CHAMFER") keys = cObject.keys() cObject[keys[0]] = ent1 cObject[keys[1]] = ent2 cObject[keys[2]] = 2 cObject[keys[3]] = 2 cObject[keys[4]] = None cObject[keys[5]] = None cObject.applyCommand()
def newArc(self): """ Create a new arc """ radius = raw_input("-->Insert the radius :") val = raw_input("-->insert The center position x,y:") xy = val.split(',') if len(xy) == 2: center = Point(xy[0], xy[1]) else: print "Errore valore incorretto inserire un valore 10,20 in questo formato" return start_angle = raw_input( "-->insert startAngle [Empty in case of circle]:") if start_angle: end_angle = raw_input("-->insert The end Angle :") else: start_angle = end_angle = 0 arc = Arc(center, float(radius), float(start_angle), float(end_angle)) self.__kr.saveEntity(arc)