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