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 SketchAPI import *
22 from salome.shaper import model
25 partSet = model.moduleDocument()
26 Parameter_R = model.addParameter(partSet, "R", "15.5")
27 Sketch_1 = model.addSketch(partSet, model.defaultPlane("XOY"))
28 SketchLine_1 = Sketch_1.addLine(0, 0, 30, 0)
29 SketchPoint_1 = Sketch_1.addPoint(model.selection("VERTEX", "Origin"))
30 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchPoint_1.result())
31 SketchLine_2 = Sketch_1.addLine(model.selection("EDGE", "OX"))
32 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.result())
33 SketchLine_3 = Sketch_1.addLine(30, 0, 30, 37.5)
34 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.startPoint())
35 SketchLine_4 = Sketch_1.addLine(30, 37.5, 17, 37.5)
36 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
37 SketchLine_5 = Sketch_1.addLine(17, 37.5, 17, 15.5)
38 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
39 SketchLine_6 = Sketch_1.addLine(17, 15.5, 0, 15.5)
40 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
41 SketchLine_7 = Sketch_1.addLine(model.selection("EDGE", "OY"))
42 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.result())
43 SketchLine_8 = Sketch_1.addLine(0, 15.5, 0, 0)
44 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_8.startPoint())
45 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_4.result())
46 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_3.result())
47 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_5.result())
48 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_6.result())
49 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_1.endPoint(), SketchLine_8.result(), 30)
50 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_3.result(), 37.5)
51 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_8.result(), "R")
52 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchPoint_1.coordinates())
53 SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_4.result(), 13)
54 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_1.startPoint())
56 Part_1 = model.addPart(partSet)
57 Part_1_doc = Part_1.document()
58 model.addParameter(Part_1_doc, "R_fillet", "0.5")
59 Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
60 SketchPoint_2 = Sketch_2.addPoint(model.selection("VERTEX", "PartSet/Origin"))
61 SketchLine_9 = Sketch_2.addLine(0, 0, 0, 45.59203984275747)
62 SketchLine_9.setAuxiliary(True)
63 SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchPoint_2.coordinates(), SketchLine_9.startPoint())
64 SketchConstraintVertical_4 = Sketch_2.setVertical(SketchLine_9.result())
65 SketchLine_10 = Sketch_2.addLine(-2.5, 37.41657386773942, -0.9611800001338426, 34.11656372860793)
66 SketchArc_1 = Sketch_2.addArc(0, 34.39248583236681, -0.9611800001338426, 34.11656372860793, 0, 33.39248583236681, False)
67 SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_10.endPoint(), SketchArc_1.startPoint())
68 SketchConstraintCoincidence_13 = Sketch_2.setCoincident(SketchArc_1.center(), SketchLine_9.result())
69 SketchConstraintAngle_1 = Sketch_2.setAngleBackward(SketchLine_10.result(), SketchLine_9.result(), 205)
70 SketchConstraintRadius_1 = Sketch_2.setRadius(SketchArc_1.results()[1], 1)
71 SketchConstraintDistance_2 = Sketch_2.setDistance(SketchLine_10.startPoint(), SketchLine_9.result(), 2.5)
72 SketchConstraintCoincidence_14 = Sketch_2.setCoincident(SketchArc_1.endPoint(), SketchLine_9.result())
73 SketchArc_2 = Sketch_2.addArc(0, 0, -2.5, 37.41657386773942, 0, 37.5, True)
74 SketchConstraintCoincidence_15 = Sketch_2.setCoincident(SketchArc_2.center(), SketchPoint_2.result())
75 SketchConstraintCoincidence_16 = Sketch_2.setCoincident(SketchLine_10.startPoint(), SketchArc_2.startPoint())
76 SketchConstraintCoincidence_17 = Sketch_2.setCoincident(SketchLine_9.result(), SketchArc_2.endPoint())
77 SketchConstraintMirror_1 = Sketch_2.addMirror(SketchLine_9.result(), [SketchLine_10.result(), SketchArc_1.results()[1], SketchArc_2.results()[1]])
78 [SketchLine_11, SketchArc_3, SketchArc_4] = SketchConstraintMirror_1.mirrored()
79 SketchMultiRotation_1_objects = [SketchArc_1.results()[1], SketchLine_10.result(), SketchArc_2.results()[1], SketchArc_3.results()[1], SketchLine_11.result(), SketchArc_4.results()[1]]
80 SketchMultiRotation_1 = Sketch_2.addRotation(SketchMultiRotation_1_objects, SketchArc_2.center(), 12, 30)
81 SketchConstraintRadius_2 = Sketch_2.setRadius(SketchArc_2.results()[1], 37.5)
83 Sketch_3 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
84 SketchLine_70 = Sketch_3.addLine(0, 0, 30, 0)
85 SketchLine_70.setAuxiliary(True)
86 SketchPoint_3 = Sketch_3.addPoint(model.selection("VERTEX", "PartSet/Origin"))
87 SketchConstraintCoincidence_18 = Sketch_3.setCoincident(SketchLine_70.startPoint(), SketchPoint_3.result())
88 SketchLine_71 = Sketch_3.addLine(30, 0, 30, 37.5)
89 SketchLine_71.setAuxiliary(True)
90 SketchConstraintCoincidence_19 = Sketch_3.setCoincident(SketchLine_70.endPoint(), SketchLine_71.startPoint())
91 SketchLine_72 = Sketch_3.addLine(30, 37.5, 17, 37.5)
92 SketchLine_72.setAuxiliary(True)
93 SketchConstraintCoincidence_20 = Sketch_3.setCoincident(SketchLine_71.endPoint(), SketchLine_72.startPoint())
94 SketchConstraintHorizontal_3 = Sketch_3.setHorizontal(SketchLine_72.result())
95 SketchConstraintHorizontal_4 = Sketch_3.setHorizontal(SketchLine_70.result())
96 SketchConstraintVertical_5 = Sketch_3.setVertical(SketchLine_71.result())
97 SketchConstraintLength_4 = Sketch_3.setLength(SketchLine_70.result(), 30)
98 SketchConstraintLength_5 = Sketch_3.setLength(SketchLine_71.result(), 37.5)
99 SketchConstraintLength_6 = Sketch_3.setLength(SketchLine_72.result(), 13)
100 SketchLine_73 = Sketch_3.addLine(29, 37.49999999999999, 30, 36.49999999999999)
101 SketchConstraintCoincidence_21 = Sketch_3.setCoincident(SketchLine_73.startPoint(), SketchLine_72.result())
102 SketchConstraintCoincidence_22 = Sketch_3.setCoincident(SketchLine_73.endPoint(), SketchLine_71.result())
103 SketchLine_74 = Sketch_3.addLine(17, 37.5, 17, 36.5)
104 SketchLine_75 = Sketch_3.addLine(17, 36.5, 17.99999999999994, 37.5)
105 SketchConstraintCoincidence_23 = Sketch_3.setCoincident(SketchLine_74.endPoint(), SketchLine_75.startPoint())
106 SketchConstraintCoincidence_24 = Sketch_3.setCoincident(SketchLine_75.endPoint(), SketchLine_72.result())
107 SketchConstraintCoincidence_25 = Sketch_3.setCoincident(SketchLine_72.endPoint(), SketchLine_74.startPoint())
108 SketchConstraintVertical_6 = Sketch_3.setVertical(SketchLine_74.result())
109 SketchConstraintLength_7 = Sketch_3.setLength(SketchLine_74.result(), 1)
110 SketchConstraintDistance_3 = Sketch_3.setDistance(SketchLine_75.endPoint(), SketchLine_74.result(), 1)
111 SketchConstraintDistance_4 = Sketch_3.setDistance(SketchLine_73.startPoint(), SketchLine_71.result(), 1)
112 SketchConstraintDistance_5 = Sketch_3.setDistance(SketchLine_73.endPoint(), SketchLine_72.result(), 1)
113 SketchLine_76 = Sketch_3.addLine(17, 37.5, 17.99999999999994, 37.5)
114 SketchConstraintCoincidence_26 = Sketch_3.setCoincident(SketchLine_72.endPoint(), SketchLine_76.startPoint())
115 SketchConstraintCoincidence_27 = Sketch_3.setCoincident(SketchLine_74.startPoint(), SketchLine_76.startPoint())
116 SketchConstraintCoincidence_28 = Sketch_3.setCoincident(SketchLine_75.endPoint(), SketchLine_76.endPoint())
117 SketchLine_77 = Sketch_3.addLine(29, 37.49999999999999, 30, 37.5)
118 SketchConstraintCoincidence_29 = Sketch_3.setCoincident(SketchLine_73.startPoint(), SketchLine_77.startPoint())
119 SketchConstraintCoincidence_30 = Sketch_3.setCoincident(SketchLine_71.endPoint(), SketchLine_77.endPoint())
120 SketchConstraintCoincidence_31 = Sketch_3.setCoincident(SketchLine_72.startPoint(), SketchLine_77.endPoint())
121 SketchLine_78 = Sketch_3.addLine(30, 37.5, 30, 36.49999999999999)
122 SketchConstraintCoincidence_32 = Sketch_3.setCoincident(SketchLine_71.endPoint(), SketchLine_78.startPoint())
123 SketchConstraintCoincidence_33 = Sketch_3.setCoincident(SketchLine_72.startPoint(), SketchLine_78.startPoint())
124 SketchConstraintCoincidence_34 = Sketch_3.setCoincident(SketchLine_77.endPoint(), SketchLine_78.startPoint())
125 SketchConstraintCoincidence_35 = Sketch_3.setCoincident(SketchLine_73.endPoint(), SketchLine_78.endPoint())
126 SketchLine_79 = Sketch_3.addLine(0, 0, 0, 15)
127 SketchLine_79.setAuxiliary(True)
128 SketchConstraintCoincidence_36 = Sketch_3.setCoincident(SketchLine_79.startPoint(), SketchPoint_3.result())
129 SketchConstraintVertical_7 = Sketch_3.setVertical(SketchLine_79.result())
130 SketchConstraintLength_8 = Sketch_3.setLength(SketchLine_79.result(), "R-R_fillet")
131 SketchLine_80 = Sketch_3.addLine(0, 15, 0.5, 15)
132 SketchLine_80.setAuxiliary(True)
133 SketchConstraintCoincidence_37 = Sketch_3.setCoincident(SketchLine_79.endPoint(), SketchLine_80.startPoint())
134 SketchConstraintHorizontal_5 = Sketch_3.setHorizontal(SketchLine_80.result())
135 SketchArc_61 = Sketch_3.addArc(0.5, 15, 0, 15, 0.5, 15.5, True)
136 SketchConstraintCoincidence_38 = Sketch_3.setCoincident(SketchLine_80.endPoint(), SketchArc_61.center())
137 SketchConstraintCoincidence_39 = Sketch_3.setCoincident(SketchLine_79.endPoint(), SketchArc_61.startPoint())
138 SketchConstraintCoincidence_40 = Sketch_3.setCoincident(SketchLine_80.startPoint(), SketchArc_61.startPoint())
139 SketchLine_81 = Sketch_3.addLine(0.5, 15, 0.5, 16)
140 SketchLine_81.setAuxiliary(True)
141 SketchConstraintCoincidence_41 = Sketch_3.setCoincident(SketchLine_80.endPoint(), SketchLine_81.startPoint())
142 SketchConstraintCoincidence_42 = Sketch_3.setCoincident(SketchArc_61.center(), SketchLine_81.startPoint())
143 SketchConstraintVertical_8 = Sketch_3.setVertical(SketchLine_81.result())
144 SketchConstraintCoincidence_43 = Sketch_3.setCoincident(SketchArc_61.endPoint(), SketchLine_81.result())
145 SketchConstraintRadius_3 = Sketch_3.setRadius(SketchArc_61.results()[1], "R_fillet")
146 SketchLine_82 = Sketch_3.addLine(0.5, 15.5, 0.5, 16)
147 SketchConstraintCoincidence_44 = Sketch_3.setCoincident(SketchArc_61.endPoint(), SketchLine_82.startPoint())
148 SketchLine_83 = Sketch_3.addLine(0.5, 16, -0.5, 16)
149 SketchConstraintCoincidence_45 = Sketch_3.setCoincident(SketchLine_82.endPoint(), SketchLine_83.startPoint())
150 SketchLine_84 = Sketch_3.addLine(-0.5, 16, -0.5, 15)
151 SketchConstraintCoincidence_46 = Sketch_3.setCoincident(SketchLine_83.endPoint(), SketchLine_84.startPoint())
152 SketchLine_85 = Sketch_3.addLine(-0.5, 15, 0, 15)
153 SketchConstraintCoincidence_47 = Sketch_3.setCoincident(SketchLine_84.endPoint(), SketchLine_85.startPoint())
154 SketchConstraintCoincidence_48 = Sketch_3.setCoincident(SketchLine_79.endPoint(), SketchLine_85.endPoint())
155 SketchConstraintCoincidence_49 = Sketch_3.setCoincident(SketchLine_80.startPoint(), SketchLine_85.endPoint())
156 SketchConstraintCoincidence_50 = Sketch_3.setCoincident(SketchArc_61.startPoint(), SketchLine_85.endPoint())
157 SketchConstraintCoincidence_51 = Sketch_3.setCoincident(SketchLine_81.endPoint(), SketchLine_83.startPoint())
158 SketchConstraintCoincidence_52 = Sketch_3.setCoincident(SketchLine_85.startPoint(), SketchLine_80.result())
159 SketchConstraintVertical_9 = Sketch_3.setVertical(SketchLine_84.result())
160 SketchConstraintHorizontal_6 = Sketch_3.setHorizontal(SketchLine_83.result())
161 SketchConstraintLength_9 = Sketch_3.setLength(SketchLine_84.result(), "2*R_fillet")
162 SketchConstraintLength_10 = Sketch_3.setLength(SketchLine_83.result(), "2*R_fillet")
164 Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("COMPOUND", "PartSet/Sketch_1")], model.selection("EDGE", "PartSet/Sketch_1/SketchLine_1"), 360, 0)
165 Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Revolution_1_1/Generated_Face&PartSet/Sketch_1/SketchLine_8"))
166 SketchPoint_4 = Sketch_4.addPoint(model.selection("VERTEX", "PartSet/Origin"))
167 SketchLine_86 = Sketch_4.addLine(0, -13.49999999999519, 3.1, -13.49999999999519)
168 SketchLine_87 = Sketch_4.addLine(model.selection("EDGE", "PartSet/OZ"))
169 SketchConstraintCoincidence_51 = Sketch_4.setCoincident(SketchLine_86.startPoint(), SketchLine_87.result())
170 SketchLine_88 = Sketch_4.addLine(3.1, -13.49999999999519, 3.1, -10.55414610473955)
171 SketchConstraintCoincidence_52 = Sketch_4.setCoincident(SketchLine_86.endPoint(), SketchLine_88.startPoint())
172 SketchLine_89 = Sketch_4.addLine(0, -10.5290802744499, 0, 12.80434395246332)
173 SketchLine_89.setAuxiliary(True)
174 SketchConstraintCoincidence_53 = Sketch_4.setCoincident(SketchLine_89.startPoint(), SketchLine_87.result())
175 SketchConstraintVertical_9 = Sketch_4.setVertical(SketchLine_89.result())
176 SketchConstraintHorizontal_6 = Sketch_4.setHorizontal(SketchLine_86.result())
177 SketchConstraintVertical_10 = Sketch_4.setVertical(SketchLine_88.result())
178 SketchConstraintLength_9 = Sketch_4.setLength(SketchLine_86.result(), 3.1)
179 SketchConstraintMirror_2 = Sketch_4.addMirror(SketchLine_87.result(), [SketchLine_86.result(), SketchLine_88.result()])
180 [SketchLine_90, SketchLine_91] = SketchConstraintMirror_2.mirrored()
181 SketchArc_62 = Sketch_4.addArc(0, 0, 3.1, -10.55414610473955, -3.100000000000001, -10.55414610473344, False)
182 SketchConstraintCoincidence_54 = Sketch_4.setCoincident(SketchPoint_4.coordinates(), SketchArc_62.center())
183 SketchConstraintCoincidence_55 = Sketch_4.setCoincident(SketchLine_87.startPoint(), SketchArc_62.center())
184 SketchConstraintCoincidence_56 = Sketch_4.setCoincident(SketchArc_62.startPoint(), SketchLine_88.result())
185 SketchConstraintCoincidence_57 = Sketch_4.setCoincident(SketchArc_62.endPoint(), SketchLine_91.result())
186 SketchConstraintRadius_4 = Sketch_4.setRadius(SketchArc_62.results()[1], 11)
187 SketchConstraintCoincidence_58 = Sketch_4.setCoincident(SketchLine_88.endPoint(), SketchArc_62.startPoint())
188 SketchPoint_5 = Sketch_4.addPoint(3.1, -10.55414610473955)
189 SketchConstraintCoincidence_59 = Sketch_4.setCoincident(SketchLine_88.endPoint(), SketchPoint_5.coordinates())
190 SketchConstraintCoincidence_60 = Sketch_4.setCoincident(SketchArc_62.startPoint(), SketchPoint_5.coordinates())
191 SketchPoint_6 = Sketch_4.addPoint(0, 11.00000000000481)
192 SketchPoint_6.setAuxiliary(True)
193 SketchConstraintCoincidence_61 = Sketch_4.setCoincident(SketchPoint_6.coordinates(), SketchArc_62.results()[1])
194 SketchConstraintCoincidence_62 = Sketch_4.setCoincident(SketchPoint_6.coordinates(), SketchLine_89.result())
195 SketchConstraintDistance_6 = Sketch_4.setDistance(SketchPoint_6.coordinates(), SketchLine_86.result(), 24.5)
197 ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), model.selection("FACE", "Revolution_1_1/Generated_Face&PartSet/Sketch_1/SketchLine_3"), 0, model.selection(), 0, [model.selection("SOLID", "Revolution_1_1")])
198 RevolutionCut_1 = model.addRevolutionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_2")], model.selection("EDGE", "PartSet/OX"), 0, 360, [model.selection("SOLID", "ExtrusionCut_1_1")])
199 ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_3")], model.selection(), 0, 5, [model.selection("SOLID", "RevolutionCut_1_1")])
202 # Test reexecution after parameter change
203 Parameter_R.setValue(16)
205 model.testResultsVolumes(ExtrusionCut_2, [64060.674439985647040884941816330])
206 Parameter_R.setValue(15)
209 from GeomAPI import GeomAPI_Shape
211 model.testNbResults(ExtrusionCut_2, 1)
212 model.testNbSubResults(ExtrusionCut_2, [0])
213 model.testNbSubShapes(ExtrusionCut_2, GeomAPI_Shape.SOLID, [1])
214 model.testNbSubShapes(ExtrusionCut_2, GeomAPI_Shape.FACE, [224])
215 model.testNbSubShapes(ExtrusionCut_2, GeomAPI_Shape.EDGE, [1314])
216 model.testNbSubShapes(ExtrusionCut_2, GeomAPI_Shape.VERTEX, [2628])
217 model.testResultsVolumes(ExtrusionCut_2, [62405.392187037912663072347640991])
219 assert(model.checkPythonDump())