]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelAPI/Test/Test2493.py
Salome HOME
Issue #19058: Error in sketch projection when changing parameter
[modules/shaper.git] / src / ModelAPI / Test / Test2493.py
1 # Copyright (C) 2014-2020  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 model.addParameter(Part_1_doc, "h1", "15")
29 model.addParameter(Part_1_doc, "h3", "7")
30 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
31 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
32 SketchPoint_1 = SketchProjection_1.createdFeature()
33 SketchCircle_1 = Sketch_1.addCircle(0, 0, 24)
34 SketchCircle_1.setAuxiliary(True)
35 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchPoint_1.result(), SketchCircle_1.center())
36 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], "48/2")
37 SketchCircle_2 = Sketch_1.addCircle(0, -24, 4)
38 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchCircle_1.results()[1], SketchCircle_2.center())
39 SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
40 SketchLine_1 = SketchProjection_2.createdFeature()
41 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchCircle_2.center(), SketchLine_1.result())
42 SketchConstraintRadius_2 = Sketch_1.setRadius(SketchCircle_2.results()[1], 4)
43 SketchLine_2 = Sketch_1.addLine(-7.50000000000032, -15.81138830084174, -7.500000000000001, -27)
44 SketchLine_2.setName("SketchLine_3")
45 SketchLine_2.result().setName("SketchLine_3")
46 SketchLine_3 = Sketch_1.addLine(-4.500000000000001, -30, 4.500000000000001, -30)
47 SketchLine_3.setName("SketchLine_4")
48 SketchLine_3.result().setName("SketchLine_4")
49 SketchLine_4 = Sketch_1.addLine(7.500000000000001, -27, 7.49999999999943, -15.81138830084217)
50 SketchLine_4.setName("SketchLine_5")
51 SketchLine_4.result().setName("SketchLine_5")
52 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
53 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_3.result())
54 SketchConstraintHorizontal_1.setName("SketchConstraintHorizontal_2")
55 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
56 SketchPoint_2 = Sketch_1.addPoint(0, -30)
57 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_3.result())
58 SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_8")
59 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchLine_1.result())
60 SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_9")
61 SketchProjection_3 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
62 SketchLine_5 = SketchProjection_3.createdFeature()
63 SketchLine_5.setName("SketchLine_6")
64 SketchLine_5.result().setName("SketchLine_6")
65 SketchArc_1 = Sketch_1.addArc(-4.500000000000001, -27, -7.500000000000001, -27, -4.500000000000001, -30, False)
66 SketchPoint_3 = Sketch_1.addPoint(-7.500000000000001, -30)
67 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchPoint_3.coordinates(), SketchLine_5.result(), 30, True)
68 SketchPoint_3.setAuxiliary(True)
69 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchPoint_3.coordinates(), SketchLine_2.result())
70 SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_11")
71 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchPoint_3.coordinates(), SketchLine_3.result())
72 SketchConstraintCoincidence_8.setName("SketchConstraintCoincidence_12")
73 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_2.endPoint())
74 SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_13")
75 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_3.startPoint())
76 SketchConstraintCoincidence_10.setName("SketchConstraintCoincidence_14")
77 SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_2.result())
78 SketchConstraintTangent_2 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_3.result())
79 SketchArc_2 = Sketch_1.addArc(4.500000000000001, -27, 4.500000000000001, -30, 7.500000000000001, -27, False)
80 SketchPoint_4 = Sketch_1.addPoint(7.5, -30)
81 SketchConstraintDistance_2 = Sketch_1.setDistance(SketchPoint_3.coordinates(), SketchPoint_4.coordinates(), 15, False)
82 SketchPoint_4.setAuxiliary(True)
83 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchPoint_4.coordinates(), SketchLine_4.result())
84 SketchConstraintCoincidence_11.setName("SketchConstraintCoincidence_15")
85 SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchPoint_4.coordinates(), SketchLine_3.result())
86 SketchConstraintCoincidence_12.setName("SketchConstraintCoincidence_16")
87 SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchArc_2.startPoint(), SketchLine_3.endPoint())
88 SketchConstraintCoincidence_13.setName("SketchConstraintCoincidence_17")
89 SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_4.startPoint())
90 SketchConstraintCoincidence_14.setName("SketchConstraintCoincidence_18")
91 SketchConstraintTangent_3 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchLine_4.result())
92 SketchConstraintTangent_4 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchLine_3.result())
93 SketchConstraintMiddle_1 = Sketch_1.setMiddlePoint(SketchPoint_2.coordinates(), SketchLine_3.result())
94 SketchConstraintRadius_4 = Sketch_1.setRadius(SketchArc_1.results()[1], 3)
95 SketchConstraintEqual_1 = Sketch_1.setEqual(SketchArc_2.results()[1], SketchArc_1.results()[1])
96 SketchArc_3 = Sketch_1.addArc(0, 0, 7.49999999999943, -15.81138830084217, 17.44306393762918, 1.410503622037278, False)
97 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchArc_3.center())
98 SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_10")
99 SketchConstraintRadius_3 = Sketch_1.setRadius(SketchArc_3.results()[1], "35/2")
100 SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchArc_3.startPoint(), SketchLine_4.endPoint())
101 SketchConstraintCoincidence_16.setName("SketchConstraintCoincidence_20")
102 SketchMultiRotation_1_objects = [SketchLine_2.result(), SketchArc_1.results()[1], SketchLine_3.result(), SketchArc_2.results()[1], SketchLine_4.result(), SketchCircle_2.results()[1]]
103 SketchMultiRotation_1 = Sketch_1.addRotation(SketchMultiRotation_1_objects, SketchAPI_Line(SketchLine_5).startPoint(), 120, 3)
104 [SketchLine_6, SketchLine_7, SketchArc_4, SketchArc_5, SketchLine_8, SketchLine_9, SketchArc_6, SketchArc_7, SketchLine_10, SketchLine_11, SketchCircle_3, SketchCircle_4] = SketchMultiRotation_1.rotated()
105 SketchLine_11.setName("SketchLine_12")
106 SketchLine_11.result().setName("SketchLine_12")
107 SketchLine_10.setName("SketchLine_9")
108 SketchLine_10.result().setName("SketchLine_9")
109 SketchArc_6.setName("SketchArc_5")
110 SketchArc_6.result().setName("SketchArc_5")
111 SketchArc_6.results()[1].setName("SketchArc_5_2")
112 SketchLine_9.setName("SketchLine_11")
113 SketchLine_9.result().setName("SketchLine_11")
114 SketchArc_5.setName("SketchArc_6")
115 SketchArc_5.result().setName("SketchArc_6")
116 SketchArc_5.results()[1].setName("SketchArc_6_2")
117 SketchLine_7.setName("SketchLine_10")
118 SketchLine_7.result().setName("SketchLine_10")
119 SketchLine_6.setName("SketchLine_7")
120 SketchLine_6.result().setName("SketchLine_7")
121 SketchArc_8 = Sketch_1.addArc(0, 0, -17.4430639376291, 1.410503622038327, -7.50000000000032, -15.81138830084174, False)
122 SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchArc_8.endPoint(), SketchLine_2.startPoint())
123 SketchConstraintCoincidence_15.setName("SketchConstraintCoincidence_21")
124 SketchConstraintEqual_2 = Sketch_1.setEqual(SketchArc_3.results()[1], SketchArc_8.results()[1])
125 SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchArc_3.center(), SketchArc_8.center())
126 SketchConstraintCoincidence_17.setName("SketchConstraintCoincidence_19")
127 SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchArc_8.startPoint(), SketchLine_11.result())
128 SketchConstraintCoincidence_18.setName("SketchConstraintCoincidence_22")
129 SketchArc_9 = Sketch_1.addArc(0, 0, 9.943063937629693, 14.40088467880386, -9.943063937628841, 14.40088467880445, False)
130 SketchConstraintCoincidence_19 = Sketch_1.setCoincident(SketchArc_9.endPoint(), SketchLine_7.result())
131 SketchConstraintCoincidence_19.setName("SketchConstraintCoincidence_23")
132 SketchConstraintEqual_3 = Sketch_1.setEqual(SketchArc_3.results()[1], SketchArc_9.results()[1])
133 SketchConstraintCoincidence_20 = Sketch_1.setCoincident(SketchArc_3.center(), SketchArc_9.center())
134 SketchConstraintCoincidence_20.setName("SketchConstraintCoincidence_24")
135 SketchConstraintCoincidence_21 = Sketch_1.setCoincident(SketchArc_3.endPoint(), SketchLine_6.result())
136 SketchConstraintCoincidence_21.setName("SketchConstraintCoincidence_25")
137 SketchConstraintCoincidence_22 = Sketch_1.setCoincident(SketchArc_9.startPoint(), SketchLine_10.result())
138 SketchConstraintCoincidence_22.setName("SketchConstraintCoincidence_26")
139 model.do()
140 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_3f-SketchArc_1_2f-SketchLine_4f-SketchArc_2_2f-SketchLine_5f-SketchArc_3_2f-SketchLine_7f-SketchArc_4_2f-SketchLine_9f-SketchArc_5_2f-SketchLine_9f-SketchArc_9_2f-SketchLine_10f-SketchArc_6_2f-SketchLine_11f-SketchArc_7_2f-SketchLine_12f-SketchArc_8_2f-SketchCircle_2_2r-SketchCircle_4_2r-SketchCircle_3_2r")], model.selection(), "h1", 0)
141 Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face"))
142 SketchLine_12 = Sketch_2.addLine(-7.499999999996014, 12.99038105676981, 7.499999999996014, 12.99038105676981)
143 SketchLine_12.setName("SketchLine_13")
144 SketchLine_12.result().setName("SketchLine_13")
145 SketchLine_13 = Sketch_2.addLine(7.499999999996014, 12.99038105676981, 15, 0)
146 SketchLine_13.setName("SketchLine_14")
147 SketchLine_13.result().setName("SketchLine_14")
148 SketchConstraintCoincidence_23 = Sketch_2.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint())
149 SketchConstraintCoincidence_23.setName("SketchConstraintCoincidence_27")
150 SketchLine_14 = Sketch_2.addLine(15, 0, 7.499999999996014, -12.99038105676981)
151 SketchLine_14.setName("SketchLine_15")
152 SketchLine_14.result().setName("SketchLine_15")
153 SketchConstraintCoincidence_24 = Sketch_2.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint())
154 SketchConstraintCoincidence_24.setName("SketchConstraintCoincidence_28")
155 SketchLine_15 = Sketch_2.addLine(7.499999999996014, -12.99038105676981, -7.499999999996014, -12.99038105676981)
156 SketchLine_15.setName("SketchLine_16")
157 SketchLine_15.result().setName("SketchLine_16")
158 SketchConstraintCoincidence_25 = Sketch_2.setCoincident(SketchLine_14.endPoint(), SketchLine_15.startPoint())
159 SketchConstraintCoincidence_25.setName("SketchConstraintCoincidence_29")
160 SketchLine_16 = Sketch_2.addLine(-7.499999999996014, -12.99038105676981, -15, 0)
161 SketchLine_16.setName("SketchLine_17")
162 SketchLine_16.result().setName("SketchLine_17")
163 SketchConstraintCoincidence_26 = Sketch_2.setCoincident(SketchLine_15.endPoint(), SketchLine_16.startPoint())
164 SketchConstraintCoincidence_26.setName("SketchConstraintCoincidence_30")
165 SketchLine_17 = Sketch_2.addLine(-15, 0, -7.499999999996014, 12.99038105676981)
166 SketchLine_17.setName("SketchLine_18")
167 SketchLine_17.result().setName("SketchLine_18")
168 SketchConstraintCoincidence_27 = Sketch_2.setCoincident(SketchLine_16.endPoint(), SketchLine_17.startPoint())
169 SketchConstraintCoincidence_27.setName("SketchConstraintCoincidence_31")
170 SketchConstraintCoincidence_28 = Sketch_2.setCoincident(SketchLine_12.startPoint(), SketchLine_17.endPoint())
171 SketchConstraintCoincidence_28.setName("SketchConstraintCoincidence_32")
172 SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_12.result())
173 SketchConstraintHorizontal_2.setName("SketchConstraintHorizontal_3")
174 SketchConstraintHorizontal_3 = Sketch_2.setHorizontal(SketchLine_15.result())
175 SketchConstraintHorizontal_3.setName("SketchConstraintHorizontal_4")
176 SketchProjection_4 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OX"), False)
177 SketchLine_18 = SketchProjection_4.createdFeature()
178 SketchLine_18.setName("SketchLine_19")
179 SketchLine_18.result().setName("SketchLine_19")
180 SketchProjection_5 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OY"), False)
181 SketchLine_19 = SketchProjection_5.createdFeature()
182 SketchLine_19.setName("SketchLine_20")
183 SketchLine_19.result().setName("SketchLine_20")
184 SketchConstraintCoincidence_29 = Sketch_2.setCoincident(SketchLine_14.startPoint(), SketchLine_18.result())
185 SketchConstraintCoincidence_29.setName("SketchConstraintCoincidence_33")
186 SketchConstraintCoincidence_30 = Sketch_2.setCoincident(SketchLine_16.endPoint(), SketchLine_18.result())
187 SketchConstraintCoincidence_30.setName("SketchConstraintCoincidence_34")
188 SketchPoint_5 = Sketch_2.addPoint(-1.694065894508601e-21, 12.99038105676981)
189 SketchConstraintCoincidence_31 = Sketch_2.setCoincident(SketchPoint_5.coordinates(), SketchLine_12.result())
190 SketchConstraintCoincidence_31.setName("SketchConstraintCoincidence_35")
191 SketchConstraintMiddle_2 = Sketch_2.setMiddlePoint(SketchLine_12.result(), SketchPoint_5.coordinates())
192 SketchConstraintCoincidence_32 = Sketch_2.setCoincident(SketchPoint_5.coordinates(), SketchLine_19.result())
193 SketchConstraintCoincidence_32.setName("SketchConstraintCoincidence_36")
194 SketchPoint_6 = Sketch_2.addPoint(-2.541098841762901e-21, -12.99038105676981)
195 SketchConstraintCoincidence_33 = Sketch_2.setCoincident(SketchPoint_6.coordinates(), SketchLine_15.result())
196 SketchConstraintCoincidence_33.setName("SketchConstraintCoincidence_37")
197 SketchConstraintCoincidence_34 = Sketch_2.setCoincident(SketchPoint_6.coordinates(), SketchLine_19.result())
198 SketchConstraintCoincidence_34.setName("SketchConstraintCoincidence_38")
199 SketchConstraintMiddle_3 = Sketch_2.setMiddlePoint(SketchLine_15.result(), SketchPoint_6.coordinates())
200 SketchCircle_5 = Sketch_2.addCircle(0, 0, 15)
201 SketchCircle_5.setAuxiliary(True)
202 SketchConstraintCoincidence_35 = Sketch_2.setCoincident(SketchAPI_Line(SketchLine_18).startPoint(), SketchCircle_5.center())
203 SketchConstraintCoincidence_35.setName("SketchConstraintCoincidence_39")
204 SketchConstraintCoincidence_36 = Sketch_2.setCoincident(SketchLine_16.endPoint(), SketchCircle_5.results()[1])
205 SketchConstraintCoincidence_36.setName("SketchConstraintCoincidence_40")
206 SketchConstraintCoincidence_37 = Sketch_2.setCoincident(SketchLine_16.startPoint(), SketchCircle_5.results()[1])
207 SketchConstraintCoincidence_37.setName("SketchConstraintCoincidence_41")
208 SketchConstraintCoincidence_38 = Sketch_2.setCoincident(SketchLine_14.startPoint(), SketchCircle_5.results()[1])
209 SketchConstraintCoincidence_38.setName("SketchConstraintCoincidence_42")
210 SketchConstraintCoincidence_39 = Sketch_2.setCoincident(SketchLine_17.endPoint(), SketchCircle_5.results()[1])
211 SketchConstraintCoincidence_39.setName("SketchConstraintCoincidence_43")
212 SketchConstraintEqual_4 = Sketch_2.setEqual(SketchLine_17.result(), SketchLine_12.result())
213 SketchConstraintEqual_5 = Sketch_2.setEqual(SketchLine_16.result(), SketchLine_15.result())
214 SketchConstraintRadius_5 = Sketch_2.setRadius(SketchCircle_5.results()[1], 15)
215 model.do()
216 Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_18r-SketchLine_17r-SketchLine_16r-SketchLine_15r-SketchLine_14r-SketchLine_13r")], model.selection(), "97-h3-h1", 0)
217 Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_2_1/To_Face"))
218 SketchProjection_6 = Sketch_3.addProjection(model.selection("EDGE", "PartSet/OX"), False)
219 SketchLine_20 = SketchProjection_6.createdFeature()
220 SketchLine_20.setName("SketchLine_21")
221 SketchLine_20.result().setName("SketchLine_21")
222 SketchCircle_6 = Sketch_3.addCircle(0, 0, 10)
223 SketchConstraintCoincidence_40 = Sketch_3.setCoincident(SketchAPI_Line(SketchLine_20).startPoint(), SketchCircle_6.center())
224 SketchConstraintCoincidence_40.setName("SketchConstraintCoincidence_44")
225 SketchConstraintRadius_6 = Sketch_3.setRadius(SketchCircle_6.results()[1], 10)
226 model.do()
227 ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_3/Face-SketchCircle_6_2f")], model.selection(), 0, 60, [model.selection("SOLID", "Extrusion_2_1")])
228 Sketch_4 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/From_Face"))
229 SketchProjection_7 = Sketch_4.addProjection(model.selection("EDGE", "PartSet/OX"), False)
230 SketchLine_21 = SketchProjection_7.createdFeature()
231 SketchLine_21.setName("SketchLine_22")
232 SketchLine_21.result().setName("SketchLine_22")
233 SketchCircle_7 = Sketch_4.addCircle(0, 0, 12.5)
234 SketchConstraintCoincidence_41 = Sketch_4.setCoincident(SketchAPI_Line(SketchLine_21).startPoint(), SketchCircle_7.center())
235 SketchConstraintCoincidence_41.setName("SketchConstraintCoincidence_45")
236 SketchConstraintRadius_7 = Sketch_4.setRadius(SketchCircle_7.results()[1], "25/2")
237 model.do()
238 # check parameter is changed, so, FromFace becomes out of resulting solid, but Sketch_4 is still valid
239 Extrusion_2.toSize().setValue(48)
240 model.end()
241
242 from ModelAPI import *
243 aFactory = ModelAPI_Session.get().validators()
244 assert(aFactory.validate(Sketch_4.feature()))