]> SALOME platform Git repositories - modules/shaper.git/blob - test.models/bobine_film_reel.py
Salome HOME
Fix compilation of CAD Builder with SALOME 9.7.0
[modules/shaper.git] / test.models / bobine_film_reel.py
1 # Copyright (C) 2014-2021  CEA/DEN, EDF R&D
2 #
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.
7 #
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.
12 #
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
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 from SketchAPI import *
21
22 from salome.shaper import model
23
24 model.begin()
25 partSet = model.moduleDocument()
26 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
28 Parameter_R = model.addParameter(Part_1_doc, "R", "40")
29 model.addParameter(Part_1_doc, "h", "3")
30 model.addParameter(Part_1_doc, "R2", "33.5")
31 model.addParameter(Part_1_doc, "h2", "4")
32 model.addParameter(Part_1_doc, "R3", "25.9")
33 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
34 SketchCircle_1 = Sketch_1.addCircle(0, 0, 40)
35 SketchPoint_1 = Sketch_1.addPoint(model.selection("VERTEX", "PartSet/Origin"))
36 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchPoint_1.result())
37 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], "R")
38 SketchLine_1 = Sketch_1.addLine(0, 0, -20.88093073029438, 34.1172497695333)
39 SketchLine_1.setAuxiliary(True)
40 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_1.startPoint())
41 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchLine_1.startPoint())
42 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchCircle_1.results()[1])
43 model.do()
44 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], model.selection(), "h", 0)
45 Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face"))
46 SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_1"))
47 SketchLine_2 = SketchProjection_1.createdFeature()
48 SketchCircle_2 = Sketch_2.addCircle(0, 0, 33.5)
49 SketchConstraintRadius_2 = Sketch_2.setRadius(SketchCircle_2.results()[1], "R2")
50 SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchAPI_Line(SketchLine_2).startPoint(), SketchCircle_2.center())
51 SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_14")
52 model.do()
53 Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_2_2f")], model.selection(), "h2", 0)
54 Extrusion_3 = model.addExtrusion(Part_1_doc, [], model.selection(), "h2*3", 0)
55 Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_2_1/To_Face"))
56 SketchCircle_3 = Sketch_3.addCircle(0, 0, 28.25)
57 SketchConstraintRadius_3 = Sketch_3.setRadius(SketchCircle_3.results()[1], 28.25)
58 SketchProjection_2 = Sketch_3.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_1"))
59 SketchLine_3 = SketchProjection_2.createdFeature()
60 SketchConstraintCoincidence_6 = Sketch_3.setCoincident(SketchCircle_3.center(), SketchAPI_Line(SketchLine_3).startPoint())
61 Extrusion_3.setNestedSketch(Sketch_3)
62 Extrusion_4 = model.addExtrusion(Part_1_doc, [], model.selection(), "h2", 0)
63 Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_3_1/To_Face"))
64 SketchProjection_3 = Sketch_4.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_1"))
65 SketchLine_4 = SketchProjection_3.createdFeature()
66 SketchCircle_4 = Sketch_4.addCircle(0, 0, 25.9)
67 SketchConstraintRadius_4 = Sketch_4.setRadius(SketchCircle_4.results()[1], "R3")
68 SketchConstraintCoincidence_7 = Sketch_4.setCoincident(SketchAPI_Line(SketchLine_4).startPoint(), SketchCircle_4.center())
69 SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_15")
70 Extrusion_4.setNestedSketch(Sketch_4)
71 Extrusion_5 = model.addExtrusion(Part_1_doc, [], model.selection(), "h2", 0)
72 Sketch_5 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_4_1/To_Face"))
73 SketchProjection_4 = Sketch_5.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_1"))
74 SketchLine_5 = SketchProjection_4.createdFeature()
75 SketchCircle_5 = Sketch_5.addCircle(0, 0, 8)
76 SketchConstraintRadius_5 = Sketch_5.setRadius(SketchCircle_5.results()[1], 8)
77 SketchConstraintCoincidence_8 = Sketch_5.setCoincident(SketchAPI_Line(SketchLine_5).startPoint(), SketchCircle_5.center())
78 SketchConstraintCoincidence_8.setName("SketchConstraintCoincidence_16")
79 Extrusion_5.setNestedSketch(Sketch_5)
80 Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Extrusion_4_1"), model.selection("SOLID", "Extrusion_5_1"), model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Extrusion_2_1"), model.selection("SOLID", "Extrusion_3_1")], [])
81 ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [], model.selection(), model.selection("FACE", "Extrusion_5_1/To_Face"), 0, model.selection(), 0, [model.selection("SOLID", "Fuse_1_1")])
82 Sketch_6 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/From_Face"))
83 SketchCircle_6 = Sketch_6.addCircle(0, 0, 4.2)
84 SketchConstraintRadius_6 = Sketch_6.setRadius(SketchCircle_6.results()[1], 4.2)
85 SketchPoint_2 = Sketch_6.addPoint(model.selection("VERTEX", "PartSet/Origin"))
86 SketchConstraintCoincidence_9 = Sketch_6.setCoincident(SketchPoint_2.coordinates(), SketchCircle_6.center())
87 SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_17")
88 ExtrusionCut_1.setNestedSketch(Sketch_6)
89 Sketch_7 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Extrusion_1_1/From_Face"))
90 SketchCircle_7 = Sketch_7.addCircle(0, -85, 66)
91 SketchLine_6 = Sketch_7.addLine(model.selection("EDGE", "PartSet/OY"))
92 SketchConstraintCoincidence_10 = Sketch_7.setCoincident(SketchCircle_7.center(), SketchLine_6.result())
93 SketchConstraintRadius_7 = Sketch_7.setRadius(SketchCircle_7.results()[1], 66)
94 SketchConstraintDistance_1 = Sketch_7.setDistance(SketchCircle_7.center(), SketchLine_6.startPoint(), 85)
95 SketchMultiRotation_1 = Sketch_7.addRotation([SketchCircle_7.results()[1]], SketchLine_6.startPoint(), 120, 3)
96 [SketchCircle_8, SketchCircle_9] = SketchMultiRotation_1.rotated()
97 model.do()
98 ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_7")], model.selection(), model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Extrusion_5_1/To_Face"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_1_1")])
99 Sketch_8 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face"))
100 SketchLine_7 = Sketch_8.addLine(-2.320957096353877e-016, 11.00000001704673, -7, 11.00000001704673)
101 SketchConstraintHorizontal_1 = Sketch_8.setHorizontal(SketchLine_7.result())
102 SketchLine_8 = Sketch_8.addLine(-7, 11.00000001704673, -6.329882773485103e-016, 30.00000001704673)
103 SketchConstraintCoincidence_11 = Sketch_8.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
104 SketchLine_9 = Sketch_8.addLine(model.selection("EDGE", "PartSet/OY"))
105 SketchConstraintCoincidence_12 = Sketch_8.setCoincident(SketchLine_7.startPoint(), SketchLine_9.result())
106 SketchConstraintCoincidence_13 = Sketch_8.setCoincident(SketchLine_8.endPoint(), SketchLine_9.result())
107 SketchConstraintMirror_1 = Sketch_8.addMirror(SketchLine_9.result(), [SketchLine_7.result(), SketchLine_8.result()])
108 [SketchLine_10, SketchLine_11] = SketchConstraintMirror_1.mirrored()
109 SketchConstraintLength_1 = Sketch_8.setLength(SketchLine_7.result(), 7)
110 SketchConstraintDistance_2 = Sketch_8.setDistance(SketchLine_9.startPoint(), SketchLine_7.result(), 11)
111 SketchConstraintDistance_3 = Sketch_8.setDistance(SketchLine_8.endPoint(), SketchLine_9.startPoint(), 30)
112 SketchMultiRotation_2_objects = [SketchLine_11.result(), SketchLine_10.result(), SketchLine_8.result(), SketchLine_7.result()]
113 SketchMultiRotation_2 = Sketch_8.addRotation(SketchMultiRotation_2_objects, SketchLine_9.startPoint(), 120, 3)
114 [SketchLine_12, SketchLine_13, SketchLine_14, SketchLine_15, SketchLine_16, SketchLine_17, SketchLine_18, SketchLine_19] = SketchMultiRotation_2.rotatedList()
115 SketchLine_18.setName("SketchLine_15")
116 SketchLine_18.result().setName("SketchLine_15")
117 SketchLine_17.setName("SketchLine_18")
118 SketchLine_17.result().setName("SketchLine_18")
119 SketchLine_16.setName("SketchLine_14")
120 SketchLine_16.result().setName("SketchLine_14")
121 SketchLine_15.setName("SketchLine_17")
122 SketchLine_15.result().setName("SketchLine_17")
123 SketchLine_14.setName("SketchLine_13")
124 SketchLine_14.result().setName("SketchLine_13")
125 SketchLine_13.setName("SketchLine_16")
126 SketchLine_13.result().setName("SketchLine_16")
127 model.do()
128 ExtrusionCut_3_objects_1 = [model.selection("FACE", "Sketch_8/Face-SketchLine_10f-SketchLine_11f-SketchLine_8r-SketchLine_7r"), model.selection("FACE", "Sketch_8/Face-SketchLine_16f-SketchLine_18r-SketchLine_19r-SketchLine_17f"), model.selection("FACE", "Sketch_8/Face-SketchLine_12f-SketchLine_14r-SketchLine_15r-SketchLine_13f")]
129 ExtrusionCut_3 = model.addExtrusionCut(Part_1_doc, ExtrusionCut_3_objects_1, model.selection(), model.selection("FACE", "ExtrusionCut_2_1/Modified_Face&Extrusion_4_1/To_Face"), 0, model.selection(), 0, [model.selection("SOLID", "ExtrusionCut_2_1")])
130
131 # Test reexecution after parameter change
132 Parameter_R.setValue(50)
133 model.do()
134 model.testResultsVolumes(ExtrusionCut_3, [35832.402050074902945198118686676])
135 Parameter_R.setValue(40)
136 model.end()
137
138 from GeomAPI import GeomAPI_Shape
139
140 model.testNbResults(ExtrusionCut_3, 1)
141 model.testNbSubResults(ExtrusionCut_3, [0])
142 model.testNbSubShapes(ExtrusionCut_3, GeomAPI_Shape.SOLID, [1])
143 model.testNbSubShapes(ExtrusionCut_3, GeomAPI_Shape.FACE, [50])
144 model.testNbSubShapes(ExtrusionCut_3, GeomAPI_Shape.EDGE, [300])
145 model.testNbSubShapes(ExtrusionCut_3, GeomAPI_Shape.VERTEX, [600])
146 model.testResultsVolumes(ExtrusionCut_3, [34439.077343526856566313654184341])
147
148 assert(model.checkPythonDump())