1 # Initialization of the test
3 from GeomDataAPI import *
4 from GeomAlgoAPI import *
8 aSession = ModelAPI_Session.get()
9 aDocument = aSession.moduleDocument()
12 aSession.startOperation()
13 aPartFeature = aDocument.addFeature("Part")
14 aSession.finishOperation()
15 aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
16 aPart = aPartResult.partDoc()
19 aSession.startOperation()
20 aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
21 anOrigin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
22 anOrigin.setValue(0, 0, 0)
23 aDirX = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
24 aDirX.setValue(1, 0, 0)
25 aNorm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
26 aNorm.setValue(0, 0, 1)
29 aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
30 aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
31 aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
32 aSketchLineStartPoint.setValue(0, 0)
33 aSketchLineEndPoint.setValue(0, 50)
34 aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
35 aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
36 aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
37 aSketchLineStartPoint.setValue(0, 50)
38 aSketchLineEndPoint.setValue(50, 50)
39 aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
40 aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
41 aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
42 aSketchLineStartPoint.setValue(50, 50)
43 aSketchLineEndPoint.setValue(50, 0)
44 aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
45 aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
46 aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
47 aSketchLineStartPoint.setValue(50, 0)
48 aSketchLineEndPoint.setValue(0, 0)
49 aSession.finishOperation()
50 aSketchResult = aSketchFeature.firstResult()
51 aSketchShape = aSketchResult.shape()
54 aSession.startOperation()
55 aWireFeature = aPart.addFeature("Wire")
56 aBaseObjectsList = aWireFeature.selectionList("base_objects")
57 aShapeExplorer = GeomAPI_ShapeExplorer(aSketchShape, GeomAPI_Shape.EDGE)
58 if aShapeExplorer.more():
59 aBaseObjectsList.append(aSketchResult, aShapeExplorer.current())
60 aWireFeature.customAction("add_contour")
61 aSession.finishOperation()
64 assert (len(aWireFeature.results()) > 0)
66 from salome.shaper import model
69 partSet = model.moduleDocument()
70 Part_1 = model.addPart(partSet)
71 Part_1_doc = Part_1.document()
72 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
73 SketchLine_1 = Sketch_1.addLine(-68.61063464837, 232.418524871355, -488.85077186964, 232.418524871355)
74 SketchLine_2 = Sketch_1.addLine(-488.85077186964, 232.418524871355, -488.85077186964, -153.516295025729)
75 SketchLine_3 = Sketch_1.addLine(-488.85077186964, -153.516295025729, -68.61063464837, -153.516295025729)
76 SketchLine_4 = Sketch_1.addLine(-68.61063464837, -153.516295025729, -68.61063464837, 232.418524871355)
77 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
78 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
79 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
80 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
81 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
82 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
83 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
84 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
86 Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")])
90 assert(model.checkPythonDump())