1 # Copyright (C) 2014-2019 CEA/DEN, EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 from salome.shaper import model
23 partSet = model.moduleDocument()
24 Part_1 = model.addPart(partSet)
25 Part_1_doc = Part_1.document()
26 Parameter_dint = model.addParameter(Part_1_doc, "dint", "58")
27 Parameter_thick = model.addParameter(Part_1_doc, "thick", "16")
28 Parameter_length = model.addParameter(Part_1_doc, "length", "172")
29 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
30 SketchLine_1 = Sketch_1.addLine(model.selection("EDGE", "PartSet/OZ"))
31 SketchArc_1 = Sketch_1.addArc(-1.656176621148808e-020, 61, -36.69142117459658, 34.94736842105263, -1.927105092898643e-024, 106, True)
32 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.result(), SketchArc_1.center())
33 SketchLine_2 = Sketch_1.addLine(model.selection("EDGE", "PartSet/OX"))
34 SketchLine_3 = Sketch_1.addLine(-46.47580015448901, 16.00000000000001, -86, 16)
35 SketchLine_4 = Sketch_1.addLine(-86, 16, -86, -1.232595164407831e-032)
36 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
37 SketchLine_5 = Sketch_1.addLine(-86, -1.232595164407831e-032, -46.47580015448901, 7.497132070176856e-024)
38 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
39 SketchArc_2 = Sketch_1.addArc(5.604803279647422e-025, 61, -23.64558253474002, 44.21052631578948, -7.759334428649666e-022, 90, True)
40 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchArc_1.center(), SketchArc_2.center())
41 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_3.result())
42 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_5.result())
43 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_4.result())
44 SketchArc_3 = Sketch_1.addArc(-46.47580015448901, 28.00000000000001, -36.69142117459658, 34.94736842105264, -46.47580015448901, 16.00000000000001, True)
45 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchArc_3.startPoint())
46 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_3.startPoint(), SketchArc_3.endPoint())
47 SketchArc_4 = Sketch_1.addArc(-46.475800154489, 28, -23.64558253474002, 44.21052631578947, -46.475800154489, -2.594279994652913e-031, True)
48 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchArc_2.startPoint(), SketchArc_4.startPoint())
49 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchArc_4.endPoint(), SketchLine_5.endPoint())
50 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_3.results()[1], 12)
51 SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchArc_3.results()[1])
52 SketchConstraintTangent_2 = Sketch_1.setTangent(SketchArc_3.results()[1], SketchLine_3.result())
53 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchArc_4.center(), SketchArc_3.center())
54 SketchConstraintTangent_3 = Sketch_1.setTangent(SketchArc_4.results()[1], SketchLine_5.result())
55 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchArc_2.center(), SketchLine_5.result(), 61)
56 SketchConstraintTangent_4 = Sketch_1.setTangent(SketchArc_4.results()[1], SketchArc_2.results()[1])
57 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_5.result())
58 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_4.result(), "thick")
59 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_1.result())
60 SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_1.result())
61 SketchConstraintDistance_2 = Sketch_1.setDistance(SketchLine_1.startPoint(), SketchLine_4.result(), "length/2")
62 SketchConstraintMirror_1_objects = [SketchArc_2.results()[1], SketchArc_4.results()[1], SketchLine_5.result(), SketchLine_4.result(), SketchLine_3.result(), SketchArc_3.results()[1], SketchArc_1.results()[1]]
63 SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_1.result(), SketchConstraintMirror_1_objects)
64 [SketchArc_5, SketchArc_6, SketchLine_6, SketchLine_7, SketchLine_8, SketchArc_7, SketchArc_8] = SketchConstraintMirror_1.mirrored()
65 SketchConstraintRadius_2 = Sketch_1.setRadius(SketchArc_2.results()[1], "dint/2")
67 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2f-SketchArc_3_2r-SketchLine_3f-SketchLine_4f-SketchLine_5f-SketchArc_4_2f-SketchArc_2_2r-SketchArc_5_2r-SketchArc_6_2f-SketchLine_6r-SketchLine_7r-SketchLine_8r-SketchArc_7_2r-SketchArc_8_2f")], model.selection(), 35, 35)
68 Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
69 SketchArc_9 = Sketch_2.addArc(0, 106, 0, 78, 0, 134, True)
70 SketchConstraintRadius_3 = Sketch_2.setRadius(SketchArc_9.results()[1], 28)
71 SketchLine_9 = Sketch_2.addLine(model.selection("EDGE", "PartSet/OX"))
72 SketchConstraintDistance_3 = Sketch_2.setDistance(SketchArc_9.center(), SketchLine_9.result(), "61+dint/2+thick")
73 SketchLine_10 = Sketch_2.addLine(model.selection("EDGE", "PartSet/OZ"))
74 SketchConstraintCoincidence_13 = Sketch_2.setCoincident(SketchArc_9.startPoint(), SketchLine_10.result())
75 SketchConstraintCoincidence_14 = Sketch_2.setCoincident(SketchArc_9.endPoint(), SketchLine_10.result())
76 SketchConstraintCoincidence_15 = Sketch_2.setCoincident(SketchArc_9.center(), SketchLine_10.result())
77 SketchLine_11 = Sketch_2.addLine(0, 78, 0, 134)
78 SketchConstraintCoincidence_16 = Sketch_2.setCoincident(SketchArc_9.startPoint(), SketchLine_11.startPoint())
79 SketchConstraintCoincidence_17 = Sketch_2.setCoincident(SketchArc_9.endPoint(), SketchLine_11.endPoint())
81 Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchArc_9_2r-SketchLine_11f")], model.selection("EDGE", "PartSet/OZ"), 360, 0)
82 Cut_1 = model.addCut(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1")], [model.selection("SOLID", "Revolution_1_1")])
83 Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "PartSet/YOZ"))
84 SketchLine_12 = Sketch_3.addLine(0, 106, -4, 106)
85 SketchLine_13 = Sketch_3.addLine(-4, 106, -4, 67.34428877022477)
86 SketchConstraintCoincidence_18 = Sketch_3.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint())
87 SketchConstraintHorizontal_3 = Sketch_3.setHorizontal(SketchLine_12.result())
88 SketchConstraintVertical_2 = Sketch_3.setVertical(SketchLine_13.result())
89 SketchPoint_1 = Sketch_3.addPoint(model.selection("VERTEX", "PartSet/Origin"))
90 SketchConstraintDistance_4 = Sketch_3.setDistance(SketchPoint_1.coordinates(), SketchLine_12.result(), "61+90/2")
91 SketchLine_14 = Sketch_3.addLine(model.selection("EDGE", "PartSet/OZ"))
92 SketchLine_14.setName("SketchLine_15")
93 SketchLine_14.result().setName("SketchLine_15")
94 SketchConstraintCoincidence_19 = Sketch_3.setCoincident(SketchLine_12.startPoint(), SketchLine_14.result())
95 SketchConstraintLength_2 = Sketch_3.setLength(SketchLine_12.result(), "8/2")
96 SketchArc_10 = Sketch_3.addArc(0, 61, -4, 67.34428877022477, 4, 67.34428877022477, False)
97 SketchConstraintCoincidence_20 = Sketch_3.setCoincident(SketchLine_14.result(), SketchArc_10.center())
98 SketchConstraintRadius_4 = Sketch_3.setRadius(SketchArc_10.results()[1], "15/2")
99 SketchLine_15 = Sketch_3.addLine(model.selection("EDGE", "PartSet/OY"))
100 SketchLine_15.setName("SketchLine_16")
101 SketchLine_15.result().setName("SketchLine_16")
102 SketchConstraintDistance_5 = Sketch_3.setDistance(SketchArc_10.center(), SketchLine_15.result(), 61)
103 SketchConstraintCoincidence_21 = Sketch_3.setCoincident(SketchLine_13.endPoint(), SketchArc_10.startPoint())
104 SketchConstraintMirror_2 = Sketch_3.addMirror(SketchLine_14.result(), [SketchLine_13.result(), SketchLine_12.result()])
105 [SketchLine_16, SketchLine_17] = SketchConstraintMirror_2.mirrored()
106 SketchLine_17.setName("SketchLine_18")
107 SketchLine_17.result().setName("SketchLine_18")
108 SketchLine_16.setName("SketchLine_17")
109 SketchLine_16.result().setName("SketchLine_17")
110 SketchConstraintCoincidence_22 = Sketch_3.setCoincident(SketchArc_10.endPoint(), SketchLine_16.result())
112 Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_3/Face-SketchLine_12r-SketchLine_13f-SketchArc_10_2f-SketchLine_17r-SketchLine_18r_wire")], model.selection(), "172/2", "172/2")
113 Cut_2 = model.addCut(Part_1_doc, [model.selection("SOLID", "Cut_1_1")], [model.selection("SOLID", "Extrusion_2_1")])
114 Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_5"))
115 SketchLine_18 = Sketch_4.addLine(-65, 16, -65, -16)
116 SketchLine_18.setName("SketchLine_19")
117 SketchLine_18.result().setName("SketchLine_19")
118 SketchLine_18.setAuxiliary(True)
119 SketchConstraintVertical_3 = Sketch_4.setVertical(SketchLine_18.result())
120 SketchConstraintLength_3 = Sketch_4.setLength(SketchLine_18.result(), 32)
121 SketchPoint_2 = Sketch_4.addPoint(model.selection("VERTEX", "PartSet/Origin"))
122 SketchConstraintDistance_6 = Sketch_4.setDistance(SketchPoint_2.coordinates(), SketchLine_18.result(), "130/2")
123 SketchPoint_3 = Sketch_4.addPoint(-65, 0)
124 SketchPoint_3.setAuxiliary(True)
125 SketchConstraintMiddle_1 = Sketch_4.setMiddlePoint(SketchPoint_3.coordinates(), SketchLine_18.result())
126 SketchLine_19 = Sketch_4.addLine(model.selection("EDGE", "PartSet/OX"))
127 SketchLine_19.setName("SketchLine_20")
128 SketchLine_19.result().setName("SketchLine_20")
129 SketchConstraintCoincidence_23 = Sketch_4.setCoincident(SketchPoint_3.coordinates(), SketchLine_19.result())
130 SketchArc_11 = Sketch_4.addArc(-65, 16, -59, 16, -71, 16, False)
131 SketchConstraintCoincidence_24 = Sketch_4.setCoincident(SketchLine_18.startPoint(), SketchArc_11.center())
132 SketchArc_12 = Sketch_4.addArc(-65, -16, -59, -16.00003459934639, -71, -16, True)
133 SketchConstraintCoincidence_25 = Sketch_4.setCoincident(SketchLine_18.endPoint(), SketchArc_12.center())
134 SketchConstraintRadius_5 = Sketch_4.setRadius(SketchArc_11.results()[1], 6)
135 SketchLine_20 = Sketch_4.addLine(-71, 16, -71, -16)
136 SketchLine_20.setName("SketchLine_21")
137 SketchLine_20.result().setName("SketchLine_21")
138 SketchConstraintCoincidence_26 = Sketch_4.setCoincident(SketchArc_11.endPoint(), SketchLine_20.startPoint())
139 SketchConstraintCoincidence_27 = Sketch_4.setCoincident(SketchArc_12.endPoint(), SketchLine_20.endPoint())
140 SketchLine_21 = Sketch_4.addLine(-59, 16, -59, -16.00003459934639)
141 SketchLine_21.setName("SketchLine_22")
142 SketchLine_21.result().setName("SketchLine_22")
143 SketchConstraintCoincidence_28 = Sketch_4.setCoincident(SketchArc_11.startPoint(), SketchLine_21.startPoint())
144 SketchConstraintCoincidence_29 = Sketch_4.setCoincident(SketchArc_12.startPoint(), SketchLine_21.endPoint())
145 SketchConstraintVertical_4 = Sketch_4.setVertical(SketchLine_20.result())
146 SketchConstraintVertical_5 = Sketch_4.setVertical(SketchLine_21.result())
147 SketchConstraintTangent_5 = Sketch_4.setTangent(SketchLine_20.result(), SketchArc_11.results()[1])
148 SketchConstraintTangent_6 = Sketch_4.setTangent(SketchLine_21.result(), SketchArc_11.results()[1])
149 SketchConstraintTangent_7 = Sketch_4.setTangent(SketchArc_12.results()[1], SketchLine_20.result())
151 Extrusion_3 = model.addExtrusion(Part_1_doc, [model.selection("WIRE", "Sketch_4/Face-SketchArc_11_2f-SketchLine_21f-SketchArc_12_2f-SketchLine_22r_wire")], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3"), 0)
152 LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("SOLID", "Extrusion_3_1")], model.selection("EDGE", "[Extrusion_1_1/To_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3]"), -130, 2)
153 Cut_3 = model.addCut(Part_1_doc, [model.selection("SOLID", "Cut_2_1")], [model.selection("COMPOUND", "LinearCopy_1_1")])
156 # Test reexecution after parameter change
157 Parameter_dint.setValue(62)
158 Parameter_thick.setValue(20)
159 Parameter_length.setValue(200)
161 model.testResultsVolumes(Cut_3, [409550.515091864974237978458404541])
162 Parameter_dint.setValue(58)
163 Parameter_thick.setValue(16)
164 Parameter_length.setValue(172)
168 from GeomAPI import GeomAPI_Shape
170 model.testNbResults(Cut_3, 1)
171 model.testNbSubResults(Cut_3, [0])
172 model.testNbSubShapes(Cut_3, GeomAPI_Shape.SOLID, [1])
173 model.testNbSubShapes(Cut_3, GeomAPI_Shape.FACE, [32])
174 model.testNbSubShapes(Cut_3, GeomAPI_Shape.EDGE, [192])
175 model.testNbSubShapes(Cut_3, GeomAPI_Shape.VERTEX, [384])
176 model.testResultsVolumes(Cut_3, [307084.534467286430299282073974609])
178 assert(model.checkPythonDump())