Salome HOME
9437c65c719f5e9fe87249faae10df480430d67d
[modules/shaper.git] / src / PythonAddons / macros / midSurface / midSurface_2.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 """Géométrie de test pour la création de surfaces médianes - Cas n°2
4 """
5
6 __revision__ = "V02.01"
7
8 nom_objet = "meli-melo"
9 fichier = "midSurface_2.stp"
10
11 import salome
12
13 salome.salome_init()
14
15 from SketchAPI import *
16
17 from salome.shaper import model
18
19 model.begin()
20 partSet = model.moduleDocument()
21 model.addParameter(partSet, "H", '24')
22 model.addParameter(partSet, "L", '36')
23 model.addParameter(partSet, "h", '2')
24 model.addParameter(partSet, "theta_1", '45')
25 model.addParameter(partSet, "C_x", '30')
26 model.addParameter(partSet, "DX", '90')
27 model.addParameter(partSet, "C_y", '40')
28 model.addParameter(partSet, "R_int", '50', 'Rayon interne')
29 model.addParameter(partSet, "R_ext", '51', 'Rayon externe')
30 model.addParameter(partSet, "R_1", '15')
31 model.addParameter(partSet, "R_2", '20')
32 model.addParameter(partSet, "R_3", '5')
33 model.addParameter(partSet, "theta_2", '60')
34 model.addParameter(partSet, "B_1", '6')
35 model.addParameter(partSet, "Ep", '0.5', 'Epaisseur')
36 model.addParameter(partSet, "Hauteur", '150.', 'Hauteur')
37 model.addParameter(partSet, "coeff", '0.00001', 'Coefficient')
38
39 # 1. Deux solides plans minces
40 #=============================
41
42 ### Create Part
43 Part_1 = model.addPart(partSet)
44 Part_1_doc = Part_1.document()
45
46 ### Create Sketch
47 Sketch_1 = model.addSketch(Part_1_doc, model.standardPlane("XOZ"))
48
49 ### Create SketchLine
50 SketchLine_1 = Sketch_1.addLine(0, 0, 48, 0)
51
52 ### Create SketchProjection
53 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
54 SketchPoint_1 = SketchProjection_1.createdFeature()
55 Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchAPI_Point(SketchPoint_1).coordinates())
56
57 ### Create SketchLine
58 SketchLine_2 = Sketch_1.addLine(48, 0, 103.7207793864215, 55.72077938642148)
59 Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
60
61 ### Create SketchLine
62 SketchLine_3 = Sketch_1.addLine(103.7207793864215, 55.72077938642148, 78.26493526370577, 81.17662350913719)
63 Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
64
65 ### Create SketchLine
66 SketchLine_4 = Sketch_1.addLine(78.26493526370577, 81.17662350913719, 0, 72)
67 Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
68
69 ### Create SketchLine
70 SketchLine_5 = Sketch_1.addLine(0, 72, 0, 0)
71 Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
72 Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_5.endPoint())
73 Sketch_1.setHorizontal(SketchLine_1.result())
74 Sketch_1.setVertical(SketchLine_5.result())
75 Sketch_1.setLength(SketchLine_5.result(), "2*L")
76 Sketch_1.setLength(SketchLine_1.result(), "2*H")
77 Sketch_1.setEqual(SketchLine_2.result(), SketchLine_4.result())
78
79 ### Create SketchProjection
80 SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
81 SketchLine_6 = SketchProjection_2.createdFeature()
82
83 ### Create SketchConstraintAngle
84 Sketch_1.setAngle(SketchLine_6.result(), SketchLine_2.result(), "theta_1", type = "Direct")
85 Sketch_1.setPerpendicular(SketchLine_2.result(), SketchLine_3.result())
86 Sketch_1.setLength(SketchLine_3.result(), "L")
87
88 ### Create SketchLine
89 SketchLine_7 = Sketch_1.addLine(0, 0, -96, 0)
90 Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_7.startPoint())
91 Sketch_1.setHorizontal(SketchLine_7.result())
92 Sketch_1.setLength(SketchLine_7.result(), "4*H")
93
94 ### Create SketchLine
95 SketchLine_8 = Sketch_1.addLine(-96, 4.800000000000001, -4.800000000000001, 4.800000000000001)
96 Sketch_1.setHorizontal(SketchLine_8.result())
97
98 ### Create SketchLine
99 SketchLine_9 = Sketch_1.addLine(-4.800000000000001, 4.800000000000001, -4.800000000000001, 72)
100 Sketch_1.setVertical(SketchLine_9.result())
101 Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint())
102
103 ### Create SketchLine
104 SketchLine_10 = Sketch_1.addLine(-4.800000000000001, 72, 0, 72)
105 Sketch_1.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint())
106 Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_10.endPoint())
107 Sketch_1.setLength(SketchLine_10.result(), "0.2*H")
108 Sketch_1.setHorizontal(SketchLine_10.result())
109
110 ### Create SketchLine
111 SketchLine_11 = Sketch_1.addLine(-96, 4.800000000000001, -96, 0)
112 Sketch_1.setCoincident(SketchLine_8.startPoint(), SketchLine_11.startPoint())
113 Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_11.endPoint())
114 Sketch_1.setVertical(SketchLine_11.result())
115 Sketch_1.setLength(SketchLine_11.result(), "0.2*H")
116 model.do()
117 Sketch_1.setName("Objet_2_Sketch")
118 Sketch_1.result().setName("Objet_2_Sketch")
119
120 ### Create Extrusion
121 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "all-in-Objet_2_Sketch")], model.selection(), "h", 0, "Faces|Wires")
122 Extrusion_1.setName("Objet_2")
123 Extrusion_1.result().setName("Objet_2")
124 Extrusion_1.result().subResult(0).setName("Extrusion_1_1_1")
125 Extrusion_1.result().subResult(1).setName("Extrusion_1_1_2")
126
127 model.do()
128
129 # 2. Un cylindre découpé
130 #=======================
131
132 ### Create Part
133 Part_2 = model.addPart(partSet)
134 Part_2_doc = Part_2.document()
135
136 ### Create Sketch
137 Sketch_2 = model.addSketch(Part_2_doc, model.standardPlane("YOZ"))
138
139 ### Create SketchCircle
140 SketchCircle_1 = Sketch_2.addCircle(30, 40, 50)
141 Sketch_2.setRadius(SketchCircle_1.results()[1], "R_int")
142
143 ### Create SketchProjection
144 SketchProjection_3 = Sketch_2.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
145 SketchPoint_2 = SketchProjection_3.createdFeature()
146 Sketch_2.setHorizontalDistance(SketchCircle_1.center(), SketchAPI_Point(SketchPoint_2).coordinates(), "C_x")
147 Sketch_2.setVerticalDistance(SketchCircle_1.center(), SketchAPI_Point(SketchPoint_2).coordinates(), "C_y")
148
149 ### Create SketchCircle
150 SketchCircle_2 = Sketch_2.addCircle(30, 40, 51)
151 Sketch_2.setRadius(SketchCircle_2.results()[1], "R_ext")
152 Sketch_2.setCoincident(SketchCircle_2.center(), SketchCircle_1.center())
153 model.do()
154 Sketch_2.setName("Objet_6_base_Sketch")
155 Sketch_2.result().setName("Objet_6_base_Sketch")
156
157 ### Create Extrusion
158 Extrusion_2 = model.addExtrusion(Part_2_doc, [model.selection("COMPOUND", "all-in-Objet_6_base_Sketch")], model.selection(), "DX", 0, "Faces|Wires")
159 Extrusion_2.setName("Objet_6_base_Extrusion")
160 Extrusion_2.result().setName("Objet_6_base_Extrusion")
161 Extrusion_2.result().subResult(0).setName("Objet_6_base_Extrusion_1")
162 Extrusion_2.result().subResult(1).setName("Objet_6_base_Extrusion_2")
163
164 ### Create Remove_SubShapes
165 Remove_SubShapes_1 = model.addRemoveSubShapes(Part_2_doc, model.selection("COMPSOLID", "Objet_6_base_Extrusion"))
166 Remove_SubShapes_1.setSubShapesToKeep([model.selection("SOLID", "Objet_6_base_Extrusion_2")])
167 Remove_SubShapes_1.setName("Objet_6_base_RemoveSubShapes")
168 Remove_SubShapes_1.result().setName("Objet_6_base")
169
170 ### Create Translation
171 Translation_1 = model.addTranslation(Part_2_doc, [model.selection("SOLID", "Objet_6_base")], vector = ["H", "L", "H+L"], keepSubResults = True)
172 Translation_1.setName("Objet_6_Translation")
173 Translation_1.result().setName("Objet_6_Translation")
174
175 ### Create Point
176 Point_2 = model.addPoint(Part_2_doc, 0, 0, 0)
177 Point_2.setName("Objet_6_Point_1")
178 Point_2.result().setName("Objet_6_Point_1")
179
180 ### Create Point
181 Point_3 = model.addPoint(Part_2_doc, 1, 2, 3)
182 Point_3.setName("Objet_6_Point_2")
183 Point_3.result().setName("Objet_6_Point_2")
184
185 ### Create Axis
186 Axis_4 = model.addAxis(Part_2_doc, model.selection("VERTEX", "Objet_6_Point_1"), model.selection("VERTEX", "Objet_6_Point_2"))
187 Axis_4.setName("Objet_6_Axe")
188 Axis_4.result().setName("Objet_6_Axe")
189
190 ### Create Rotation
191 Rotation_1 = model.addRotation(Part_2_doc, [model.selection("SOLID", "Objet_6_Translation")], axis = model.selection("EDGE", "Objet_6_Axe"), angle = 30, keepSubResults = True)
192 Rotation_1.setName("Objet_6_Rotation")
193 Rotation_1.result().setName("Objet_6_Rotation")
194
195 ### Create Sketch
196 Sketch_3 = model.addSketch(Part_2_doc, model.standardPlane("XOY"))
197
198 ### Create SketchLine
199 SketchLine_12 = Sketch_3.addLine(36, 120, 59.99999999999999, 78.43078061834694)
200
201 ### Create SketchLine
202 SketchLine_13 = Sketch_3.addLine(59.99999999999999, 78.43078061834694, 80.78460969082653, 90.43078061834694)
203 Sketch_3.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint())
204
205 ### Create SketchLine
206 SketchLine_14 = Sketch_3.addLine(80.78460969082653, 90.43078061834694, 104.7846096908265, 48.86156123669388)
207 Sketch_3.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint())
208
209 ### Create SketchLine
210 SketchLine_15 = Sketch_3.addLine(104.7846096908265, 48.86156123669388, 60.37400840781982, 30.64896961216652)
211 Sketch_3.setCoincident(SketchLine_14.endPoint(), SketchLine_15.startPoint())
212
213 ### Create SketchLine
214 SketchLine_16 = Sketch_3.addLine(60.37400840781982, 30.64896961216652, 36, 72)
215 Sketch_3.setCoincident(SketchLine_15.endPoint(), SketchLine_16.startPoint())
216
217 ### Create SketchLine
218 SketchLine_17 = Sketch_3.addLine(36, 72, 36, 120)
219 Sketch_3.setCoincident(SketchLine_16.endPoint(), SketchLine_17.startPoint())
220 Sketch_3.setCoincident(SketchLine_12.startPoint(), SketchLine_17.endPoint())
221 Sketch_3.setVertical(SketchLine_17.result())
222 Sketch_3.setEqual(SketchLine_17.result(), SketchLine_12.result())
223 Sketch_3.setEqual(SketchLine_12.result(), SketchLine_15.result())
224 Sketch_3.setPerpendicular(SketchLine_13.result(), SketchLine_14.result())
225 Sketch_3.setPerpendicular(SketchLine_13.result(), SketchLine_12.result())
226 Sketch_3.setEqual(SketchLine_14.result(), SketchLine_16.result())
227
228 ### Create SketchProjection
229 SketchProjection_4 = Sketch_3.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
230 SketchPoint_3 = SketchProjection_4.createdFeature()
231 Sketch_3.setHorizontalDistance(SketchAPI_Point(SketchPoint_3).coordinates(), SketchLine_16.endPoint(), "L")
232 Sketch_3.setVerticalDistance(SketchAPI_Point(SketchPoint_3).coordinates(), SketchLine_16.endPoint(), "2*L")
233 Sketch_3.setLength(SketchLine_14.result(), "2.*H")
234 Sketch_3.setLength(SketchLine_13.result(), "H")
235
236 ### Create SketchConstraintAngle
237 Sketch_3.setAngle(SketchLine_17.result(), SketchLine_12.result(), 30, type = "Direct")
238 Sketch_3.setLength(SketchLine_15.result(), "2.*H")
239 model.do()
240 Sketch_3.setName("Objet_6_Sketch_bloc_a")
241 Sketch_3.result().setName("Objet_6_Sketch_bloc_a")
242
243 ### Create Extrusion
244 Extrusion_3 = model.addExtrusion(Part_2_doc, [model.selection("COMPOUND", "Objet_6_Sketch_bloc_a")], model.selection(), 200, 100, "Faces|Wires")
245 Extrusion_3.setName("Objet_6_a")
246 Extrusion_3.result().setName("Objet_6_a")
247
248 ### Create Common
249 Common_1 = model.addCommon(Part_2_doc, [model.selection("SOLID", "Objet_6_Rotation"), model.selection("SOLID", "Objet_6_a")], keepSubResults = True)
250 Common_1.setName("Objet_6")
251 Common_1.result().setName("Objet_6")
252 Common_1.result().subResult(0).setName("Common_1_1_1")
253 Common_1.result().subResult(1).setName("Common_1_1_2")
254 Folder_1 = model.addFolder(Part_2_doc, Sketch_2, Extrusion_3)
255 Folder_1.setName("Objet_6_création")
256
257 model.do()
258
259 # 3. Un tore découpé
260 #===================
261
262 ### Create Part
263 Part_3 = model.addPart(partSet)
264 Part_3_doc = Part_3.document()
265
266 ### Create Torus
267 Torus_1 = model.addTorus(Part_3_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), "R_2", "R_3")
268 Torus_1.setName("Objet_8_Tore_1")
269 Torus_1.result().setName("Objet_8_Tore_1")
270
271 ### Create Torus
272 Torus_2 = model.addTorus(Part_3_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), "R_2", "R_3-h")
273 Torus_2.setName("Objet_8_Tore_2")
274 Torus_2.result().setName("Objet_8_Tore_2")
275
276 ### Create Cut
277 Cut_1 = model.addCut(Part_3_doc, [model.selection("SOLID", "Objet_8_Tore_1")], [model.selection("SOLID", "Objet_8_Tore_2")], keepSubResults = True)
278 Cut_1.setName("Objet_8_Cut")
279 Cut_1.result().setName("Objet_8_Cut")
280
281 ### Create Sketch
282 Sketch_4 = model.addSketch(Part_3_doc, model.standardPlane("XOY"))
283
284 ### Create SketchLine
285 SketchLine_18 = Sketch_4.addLine(0, 33.9282032302755, 6, 33.9282032302755)
286 Sketch_4.setHorizontal(SketchLine_18.result())
287
288 ### Create SketchLine
289 SketchLine_19 = Sketch_4.addLine(6, 33.9282032302755, 6, 5)
290 Sketch_4.setCoincident(SketchLine_18.endPoint(), SketchLine_19.startPoint())
291 Sketch_4.setVertical(SketchLine_19.result())
292
293 ### Create SketchLine
294 SketchLine_20 = Sketch_4.addLine(6, 5, 31.05255888325765, -9.464101615137745)
295 Sketch_4.setCoincident(SketchLine_19.endPoint(), SketchLine_20.startPoint())
296
297 ### Create SketchLine
298 SketchLine_21 = Sketch_4.addLine(31.05255888325765, -9.464101615137745, 25.05255888325765, -19.85640646055101)
299 Sketch_4.setCoincident(SketchLine_20.endPoint(), SketchLine_21.startPoint())
300
301 ### Create SketchLine
302 SketchLine_22 = Sketch_4.addLine(25.05255888325765, -19.85640646055101, 6, -8.856406460550954)
303 Sketch_4.setCoincident(SketchLine_21.endPoint(), SketchLine_22.startPoint())
304
305 ### Create SketchLine
306 SketchLine_23 = Sketch_4.addLine(6, -8.856406460550954, 6, -28.8564064605506)
307 Sketch_4.setCoincident(SketchLine_22.endPoint(), SketchLine_23.startPoint())
308 Sketch_4.setVertical(SketchLine_23.result())
309
310 ### Create SketchLine
311 SketchLine_24 = Sketch_4.addLine(6, -28.8564064605506, 0, -28.8564064605506)
312 Sketch_4.setCoincident(SketchLine_23.endPoint(), SketchLine_24.startPoint())
313 Sketch_4.setHorizontal(SketchLine_24.result())
314
315 ### Create SketchProjection
316 SketchProjection_5 = Sketch_4.addProjection(model.selection("EDGE", "PartSet/OY"), False)
317 SketchLine_25 = SketchProjection_5.createdFeature()
318 Sketch_4.setCoincident(SketchLine_18.startPoint(), SketchLine_25.result())
319 Sketch_4.setCoincident(SketchLine_24.endPoint(), SketchLine_25.result())
320 Sketch_4.setEqual(SketchLine_18.result(), SketchLine_24.result())
321 Sketch_4.setPerpendicular(SketchLine_20.result(), SketchLine_21.result())
322 Sketch_4.setPerpendicular(SketchLine_22.result(), SketchLine_21.result())
323
324 ### Create SketchConstraintAngle
325 Sketch_4.setAngle(SketchLine_23.result(), SketchLine_22.result(), "theta_2", type = "Direct")
326 Sketch_4.setLength(SketchLine_18.result(), "B_1")
327 Sketch_4.setLength(SketchLine_21.result(), "2.*B_1")
328
329 ### Create SketchProjection
330 SketchProjection_6 = Sketch_4.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
331 SketchPoint_4 = SketchProjection_6.createdFeature()
332 Sketch_4.setVerticalDistance(SketchLine_20.startPoint(), SketchAPI_Point(SketchPoint_4).coordinates(), "R_2/4.")
333 Sketch_4.setLength(SketchLine_22.result(), "1.1*R_2")
334 Sketch_4.setLength(SketchLine_23.result(), "R_2")
335 Sketch_4.setEqual(SketchLine_20.result(), SketchLine_19.result())
336
337 ### Create SketchConstraintMirror
338 SketchConstraintMirror_1_objects = [SketchLine_24.result(), SketchLine_23.result(), SketchLine_18.result(), SketchLine_19.result(), SketchLine_21.result(), SketchLine_20.result(), SketchLine_22.result()]
339 SketchConstraintMirror_1 = Sketch_4.addMirror(SketchLine_25.result(), SketchConstraintMirror_1_objects)
340 [SketchLine_26, SketchLine_27, SketchLine_28, SketchLine_29, SketchLine_30, SketchLine_31, SketchLine_32] = SketchConstraintMirror_1.mirrored()
341 model.do()
342 Sketch_4.setName("Objet_8_Sketch_bloc_b")
343 Sketch_4.result().setName("Objet_8_Sketch_bloc_b")
344
345 ### Create Extrusion
346 Extrusion_4 = model.addExtrusion(Part_3_doc, [model.selection("COMPOUND", "Objet_8_Sketch_bloc_b")], model.selection(), "4.*R_3", "4.*R_3", "Faces|Wires")
347 Extrusion_4.setName("Objet_8_b")
348 Extrusion_4.result().setName("Objet_8_b")
349
350 ### Create Common
351 Common_2 = model.addCommon(Part_3_doc, [model.selection("SOLID", "Objet_8_Cut"), model.selection("SOLID", "Objet_8_b")], keepSubResults = True)
352 Common_2.setName("Objet_8_Common")
353 Common_2.result().setName("Objet_8_Common")
354 Common_2.result().subResult(0).setName("Common_1_1_1")
355 Common_2.result().subResult(1).setName("Common_1_1_2")
356 Common_2.result().subResult(2).setName("Common_1_1_3")
357 Common_2.result().subResult(3).setName("Common_1_1_4")
358
359 ### Create Point
360 Point_4 = model.addPoint(Part_3_doc, -1, -2, -3)
361 Point_4.setName("Objet_8_Point_1")
362 Point_4.result().setName("Objet_8_Point_1")
363
364 ### Create Point
365 Point_5 = model.addPoint(Part_3_doc, 20, 30, 15)
366 Point_5.setName("Objet_8_Point_2")
367 Point_5.result().setName("Objet_8_Point_2")
368
369 ### Create Axis
370 Axis_5 = model.addAxis(Part_3_doc, model.selection("VERTEX", "Objet_8_Point_1"), model.selection("VERTEX", "Objet_8_Point_2"))
371 Axis_5.setName("Objet_8_Axe")
372 Axis_5.result().setName("Objet_8_Axe")
373
374 ### Create Rotation
375 Rotation_2 = model.addRotation(Part_3_doc, [model.selection("COMPOUND", "Objet_8_Common")], axis = model.selection("EDGE", "Objet_8_Axe"), angle = 45, keepSubResults = True)
376 Rotation_2.setName("Objet_8")
377 Rotation_2.result().setName("Objet_8")
378 Rotation_2.result().subResult(0).setName("Rotation_1_1_1")
379 Rotation_2.result().subResult(1).setName("Rotation_1_1_2")
380 Rotation_2.result().subResult(2).setName("Rotation_1_1_3")
381 Rotation_2.result().subResult(3).setName("Rotation_1_1_4")
382 Folder_2 = model.addFolder(Part_3_doc, Torus_1, Axis_5)
383 Folder_2.setName("Objet_8_création")
384
385 model.do()
386
387 # 4. Un cône découpé
388 #===================
389
390 ### Create Part
391 Part_4 = model.addPart(partSet)
392 Part_4_doc = Part_4.document()
393
394 ### Create Cone
395 Cone_1 = model.addCone(Part_4_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), "R_2", "R_3", "DX")
396 Cone_1.setName("Objet_9_Cone_1")
397 Cone_1.result().setName("Objet_9_Cone_1")
398
399 ### Create Cone
400 Cone_2 = model.addCone(Part_4_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), "R_2-h", "R_3-h", "DX")
401 Cone_2.setName("Objet_9_Cone_2")
402 Cone_2.result().setName("Objet_9_Cone_2")
403
404 ### Create Cut
405 Cut_2 = model.addCut(Part_4_doc, [model.selection("SOLID", "Objet_9_Cone_1")], [model.selection("SOLID", "Objet_9_Cone_2")], keepSubResults = True)
406 Cut_2.setName("Objet_9_Cut")
407 Cut_2.result().setName("Objet_9_Cut")
408
409 ### Create Sketch
410 Sketch_5 = model.addSketch(Part_4_doc, model.standardPlane("XOY"))
411
412 ### Create SketchLine
413 SketchLine_33 = Sketch_5.addLine(0, 33.9282032302755, 6, 33.9282032302755)
414 Sketch_5.setHorizontal(SketchLine_33.result())
415
416 ### Create SketchLine
417 SketchLine_34 = Sketch_5.addLine(6, 33.9282032302755, 6, 5)
418 Sketch_5.setCoincident(SketchLine_33.endPoint(), SketchLine_34.startPoint())
419 Sketch_5.setVertical(SketchLine_34.result())
420
421 ### Create SketchLine
422 SketchLine_35 = Sketch_5.addLine(6, 5, 31.05255888325765, -9.464101615137745)
423 Sketch_5.setCoincident(SketchLine_34.endPoint(), SketchLine_35.startPoint())
424
425 ### Create SketchLine
426 SketchLine_36 = Sketch_5.addLine(31.05255888325765, -9.464101615137745, 25.05255888325765, -19.85640646055101)
427 Sketch_5.setCoincident(SketchLine_35.endPoint(), SketchLine_36.startPoint())
428
429 ### Create SketchLine
430 SketchLine_37 = Sketch_5.addLine(25.05255888325765, -19.85640646055101, 6, -8.856406460550954)
431 Sketch_5.setCoincident(SketchLine_36.endPoint(), SketchLine_37.startPoint())
432
433 ### Create SketchLine
434 SketchLine_38 = Sketch_5.addLine(6, -8.856406460550954, 6, -28.8564064605506)
435 Sketch_5.setCoincident(SketchLine_37.endPoint(), SketchLine_38.startPoint())
436 Sketch_5.setVertical(SketchLine_38.result())
437
438 ### Create SketchLine
439 SketchLine_39 = Sketch_5.addLine(6, -28.8564064605506, 0, -28.8564064605506)
440 Sketch_5.setCoincident(SketchLine_38.endPoint(), SketchLine_39.startPoint())
441 Sketch_5.setHorizontal(SketchLine_39.result())
442
443 ### Create SketchProjection
444 SketchProjection_7 = Sketch_5.addProjection(model.selection("EDGE", "PartSet/OY"), False)
445 SketchLine_40 = SketchProjection_7.createdFeature()
446 Sketch_5.setCoincident(SketchLine_33.startPoint(), SketchLine_40.result())
447 Sketch_5.setCoincident(SketchLine_39.endPoint(), SketchLine_40.result())
448 Sketch_5.setEqual(SketchLine_33.result(), SketchLine_39.result())
449 Sketch_5.setPerpendicular(SketchLine_35.result(), SketchLine_36.result())
450 Sketch_5.setPerpendicular(SketchLine_37.result(), SketchLine_36.result())
451
452 ### Create SketchConstraintAngle
453 Sketch_5.setAngle(SketchLine_38.result(), SketchLine_37.result(), "theta_2", type = "Direct")
454 Sketch_5.setLength(SketchLine_33.result(), "B_1")
455 Sketch_5.setLength(SketchLine_36.result(), "2.*B_1")
456
457 ### Create SketchProjection
458 SketchProjection_8 = Sketch_5.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
459 SketchPoint_5 = SketchProjection_8.createdFeature()
460 Sketch_5.setVerticalDistance(SketchLine_35.startPoint(), SketchAPI_Point(SketchPoint_5).coordinates(), "R_2/4.")
461 Sketch_5.setLength(SketchLine_37.result(), "1.1*R_2")
462 Sketch_5.setLength(SketchLine_38.result(), "R_2")
463 Sketch_5.setEqual(SketchLine_35.result(), SketchLine_34.result())
464
465 ### Create SketchConstraintMirror
466 SketchConstraintMirror_2_objects = [SketchLine_39.result(), SketchLine_38.result(), SketchLine_33.result(), SketchLine_34.result(), SketchLine_36.result(), SketchLine_35.result(), SketchLine_37.result()]
467 SketchConstraintMirror_2 = Sketch_5.addMirror(SketchLine_40.result(), SketchConstraintMirror_2_objects)
468 [SketchLine_41, SketchLine_42, SketchLine_43, SketchLine_44, SketchLine_45, SketchLine_46, SketchLine_47] = SketchConstraintMirror_2.mirrored()
469 model.do()
470 Sketch_5.setName("Objet_9_Sketch_bloc_b")
471 Sketch_5.result().setName("Objet_9_Sketch_bloc_b")
472
473 ### Create Extrusion
474 Extrusion_5 = model.addExtrusion(Part_4_doc, [model.selection("COMPOUND", "Objet_9_Sketch_bloc_b")], model.selection(), "4.*R_3", "4.*R_3", "Faces|Wires")
475 Extrusion_5.setName("Objet_9_b")
476 Extrusion_5.result().setName("Objet_9_b")
477
478 ### Create Rotation
479 Rotation_3 = model.addRotation(Part_4_doc, [model.selection("SOLID", "Objet_9_b")], axis = model.selection("EDGE", "PartSet/OX"), angle = 10, keepSubResults = True)
480 Rotation_3.setName("Objet_9_b_1")
481 Rotation_3.result().setName("Objet_9_b_1")
482
483 ### Create Common
484 Common_3 = model.addCommon(Part_4_doc, [model.selection("SOLID", "Objet_9_Cut"), model.selection("SOLID", "Objet_9_b_1")], keepSubResults = True)
485 Common_3.setName("Objet_9_Common")
486 Common_3.result().setName("Objet_9_Common")
487 Common_3.result().subResult(0).setName("Common_1_1_1")
488 Common_3.result().subResult(1).setName("Common_1_1_2")
489 Common_3.result().subResult(2).setName("Common_1_1_3")
490 Common_3.result().subResult(3).setName("Common_1_1_4")
491
492 ### Create Translation
493 Translation_2 = model.addTranslation(Part_4_doc, [model.selection("COMPOUND", "all-in-Objet_9_Common")], axis = model.selection("EDGE", "PartSet/OZ"), distance = "-2*R_2", keepSubResults = True)
494 Translation_2.setName("Objet_9_Common")
495 Translation_2.result().setName("Objet_9_Common")
496 Translation_2.result().subResult(0).setName("Translation_1_1_1")
497 Translation_2.result().subResult(0).subResult(0).setName("Translation_1_1_1_1")
498 Translation_2.result().subResult(0).subResult(1).setName("Translation_1_1_1_2")
499 Translation_2.result().subResult(0).subResult(2).setName("Translation_1_1_1_3")
500 Translation_2.result().subResult(0).subResult(3).setName("Translation_1_1_1_4")
501
502 ### Create Point
503 Point_6 = model.addPoint(Part_4_doc, -1, -2, -3)
504 Point_6.setName("Objet_9_Point_1")
505 Point_6.result().setName("Objet_9_Point_1")
506
507 ### Create Point
508 Point_7 = model.addPoint(Part_4_doc, 20, 30, 15)
509 Point_7.setName("Objet_9_Point_2")
510 Point_7.result().setName("Objet_9_Point_2")
511
512 ### Create Axis
513 Axis_6 = model.addAxis(Part_4_doc, model.selection("VERTEX", "Objet_9_Point_1"), model.selection("VERTEX", "Objet_9_Point_2"))
514 Axis_6.setName("Objet_9_Axe")
515 Axis_6.result().setName("Objet_9_Axe")
516
517 ### Create Rotation
518 Rotation_4 = model.addRotation(Part_4_doc, [model.selection("COMPOUND", "Objet_9_Common")], axis = model.selection("EDGE", "Objet_9_Axe"), angle = 45, keepSubResults = True)
519 Rotation_4.setName("Objet_9")
520 Rotation_4.result().setName("Objet_9")
521 Rotation_4.result().subResult(0).setName("Rotation_2_1_1")
522 Rotation_4.result().subResult(0).subResult(0).setName("Rotation_2_1_1_1")
523 Rotation_4.result().subResult(0).subResult(1).setName("Rotation_2_1_1_2")
524 Rotation_4.result().subResult(0).subResult(2).setName("Rotation_2_1_1_3")
525 Rotation_4.result().subResult(0).subResult(3).setName("Rotation_2_1_1_4")
526 Folder_3 = model.addFolder(Part_4_doc, Cone_1, Axis_6)
527 Folder_3.setName("Objet_9_création")
528
529 model.do()
530
531 # 5. Assemblage des composants
532 #=============================
533
534 ### Create Part
535 Part_5 = model.addPart(partSet)
536 Part_5_doc = Part_5.document()
537
538 ### Create ImportResult
539 ImportResult_1_objects = [model.selection("COMPOUND", "Part_4/Objet_9"),
540                           model.selection("COMPOUND", "Part_3/Objet_8"),
541                           model.selection("COMPOUND", "Part_2/Objet_6"),
542                           model.selection("COMPSOLID", "Part_1/Objet_2")]
543 ImportResult_1 = model.addImportResult(Part_5_doc, ImportResult_1_objects)
544
545 ### Create Partition
546 Partition_1_objects = [model.selection("COMPOUND", "ImportResult_1_1"),
547                        model.selection("COMPOUND", "ImportResult_1_2"),
548                        model.selection("COMPOUND", "ImportResult_1_3"),
549                        model.selection("COMPSOLID", "ImportResult_1_4")]
550 Partition_1 = model.addPartition(Part_5_doc, Partition_1_objects, keepSubResults = True)
551 Partition_1.result().setName(nom_objet)
552
553 ### Exportation
554 print ("Exportation dans {}".format(fichier))
555 export = model.exportToFile(Part_5_doc, fichier, [model.selection("COMPSOLID", nom_objet)])
556
557 model.end()
558
559 if salome.sg.hasDesktop():
560   salome.sg.updateObjBrowser()