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