1 # Initialization of the test
3 from GeomDataAPI import *
4 from GeomAlgoAPI import *
9 def createPoint(theSketchFeature):
10 aSketchPointFeature = theSketchFeature.addFeature("SketchPoint")
11 aPointCoordindates = geomDataAPI_Point2D(aSketchPointFeature.attribute("PointCoordindates"))
12 aPointCoordindates.setValue(random.uniform(0, 100), random.uniform(0, 100))
13 return aSketchPointFeature
16 aSession = ModelAPI_Session.get()
17 aDocument = aSession.moduleDocument()
20 aSession.startOperation()
21 aPartFeature = aDocument.addFeature("Part")
22 aSession.finishOperation()
23 aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
24 aPart = aPartResult.partDoc()
27 aSession.startOperation()
28 aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
29 anOrigin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
30 anOrigin.setValue(0, 0, 0)
31 aDirX = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
32 aDirX.setValue(1, 0, 0)
33 aNorm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
34 aNorm.setValue(0, 0, 1)
39 for i in range(aNumOfPoints):
40 aSession.startOperation()
41 aSketchPointFeature = createPoint(aSketchFeature)
42 aSession.finishOperation()
43 aPoints.append(aSketchPointFeature.firstResult().shape())
44 aSession.finishOperation()
45 aSketchResult = aSketchFeature.firstResult()
48 aSession.startOperation()
49 aVertexFeature = aPart.addFeature("Vertex")
50 aBaseObjectsList = aVertexFeature.selectionList("base_objects")
52 for aPoint in aPoints:
53 aBaseObjectsList.append(aSketchResult, aPoint)
54 aSession.finishOperation()
57 assert (len(aVertexFeature.results()) == aNumOfPoints)