Salome HOME
513d0e396bc00925bc27d51cfa4f041f29f7b46b
[modules/shaper.git] / src / FeaturesPlugin / Test / Test1942.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 salome.shaper import model
21
22 model.begin()
23 partSet = model.moduleDocument()
24 Point_2 = model.addPoint(partSet, 100, 40, 70)
25 Axis_4 = model.addAxis(partSet, model.selection("VERTEX", "Origin"), model.selection("VERTEX", "Point_2"))
26 Plane_4 = model.addPlane(partSet, model.selection("EDGE", "Axis_4"), model.selection("VERTEX", "Point_2"), True)
27 Part_1 = model.addPart(partSet)
28 Part_1_doc = Part_1.document()
29 model.addParameter(Part_1_doc, "a", "100")
30 Sketch_1 = model.addSketch(Part_1_doc, model.selection("FACE", "PartSet/Plane_4"))
31 SketchLine_1 = Sketch_1.addLine(-5.024014514861164, -46.57477619916804, -15.03025649976126, -42.91660461599292)
32 SketchLine_1.setName("SketchLine_9")
33 SketchLine_1.result().setName("SketchLine_9")
34 SketchLine_2 = Sketch_1.addLine(-34.15308715195452, -20.5925185611531, -39.51293324824182, 6.356619200673476)
35 SketchLine_2.setName("SketchLine_10")
36 SketchLine_2.result().setName("SketchLine_10")
37 SketchLine_3 = Sketch_1.addLine(-5.024014514861164, -46.57477619916804, -30.86442523156243, -37.12780736470863)
38 SketchLine_3.setName("SketchLine_1")
39 SketchLine_3.result().setName("SketchLine_1")
40 SketchLine_3.setAuxiliary(True)
41 SketchLine_4 = Sketch_1.addLine(-30.86442523156243, -37.12780736470863, -39.51293324824182, 6.356619200673476)
42 SketchLine_4.setName("SketchLine_2")
43 SketchLine_4.result().setName("SketchLine_2")
44 SketchLine_4.setAuxiliary(True)
45 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
46 SketchLine_5 = Sketch_1.addLine(-21.88471935002519, 39.79243387785534, 5.516674902531107, 51.5099134867221)
47 SketchLine_5.setName("SketchLine_4")
48 SketchLine_5.result().setName("SketchLine_4")
49 SketchLine_6 = Sketch_1.addLine(5.516674902531107, 51.5099134867221, 32.11790618078412, 35.7788047045564)
50 SketchLine_6.setName("SketchLine_5")
51 SketchLine_6.result().setName("SketchLine_5")
52 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
53 SketchConstraintCoincidence_2.setName("SketchConstraintCoincidence_4")
54 SketchLine_7 = Sketch_1.addLine(32.11790618078412, 35.7788047045564, 51.23593736581751, -10.42185420425237)
55 SketchLine_7.setName("SketchLine_6")
56 SketchLine_7.result().setName("SketchLine_6")
57 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
58 SketchConstraintCoincidence_3.setName("SketchConstraintCoincidence_5")
59 SketchLine_8 = Sketch_1.addLine(51.23593736581751, -10.42185420425237, 33.52471395405271, -30.09043472300023)
60 SketchLine_8.setName("SketchLine_7")
61 SketchLine_8.result().setName("SketchLine_7")
62 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
63 SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_6")
64 SketchLine_9 = Sketch_1.addLine(33.52471395405271, -30.09043472300023, -5.024014514861164, -46.57477619916804)
65 SketchLine_9.setName("SketchLine_8")
66 SketchLine_9.result().setName("SketchLine_8")
67 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint())
68 SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_7")
69 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_3.startPoint(), SketchLine_9.endPoint())
70 SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_8")
71 SketchArc_1 = Sketch_1.addArc(-4.72938863253667, -14.74051331180418, -34.15308715195452, -20.5925185611531, -15.03025649976126, -42.91660461599292, False)
72 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_2.startPoint())
73 SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_9")
74 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_1.endPoint())
75 SketchConstraintCoincidence_8.setName("SketchConstraintCoincidence_10")
76 SketchConstraintTangent_1 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_1.result())
77 SketchConstraintTangent_2 = Sketch_1.setTangent(SketchArc_1.results()[1], SketchLine_2.result())
78 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_3.startPoint(), SketchLine_1.startPoint())
79 SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_11")
80 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_2.endPoint())
81 SketchConstraintCoincidence_10.setName("SketchConstraintCoincidence_12")
82 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_3.result())
83 SketchConstraintCoincidence_11.setName("SketchConstraintCoincidence_13")
84 SketchConstraintCoincidence_12 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchLine_4.result())
85 SketchConstraintCoincidence_12.setName("SketchConstraintCoincidence_14")
86 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 30)
87 SketchArc_2 = Sketch_1.addArc(-10.08923472882396, 12.20862445002239, -39.51293324824182, 6.356619200673476, -21.88471935002519, 39.79243387785534, True)
88 SketchConstraintRadius_2 = Sketch_1.setRadius(SketchArc_2.results()[1], 30)
89 SketchConstraintCoincidence_13 = Sketch_1.setCoincident(SketchArc_2.startPoint(), SketchLine_2.endPoint())
90 SketchConstraintCoincidence_13.setName("SketchConstraintCoincidence_15")
91 SketchConstraintTangent_3 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchLine_2.result())
92 SketchConstraintCoincidence_14 = Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchArc_2.endPoint())
93 SketchConstraintCoincidence_14.setName("SketchConstraintCoincidence_16")
94 SketchConstraintTangent_4 = Sketch_1.setTangent(SketchLine_5.result(), SketchArc_2.results()[1])
95 SketchConstraintParallel_1 = Sketch_1.setParallel(SketchLine_5.result(), SketchLine_9.result())
96 SketchCircle_1 = Sketch_1.addCircle(2.333185352801025, 5.209035955269018, 34.7006180228472)
97 SketchCircle_1.setName("SketchCircle_2")
98 SketchCircle_1.result().setName("SketchCircle_2")
99 SketchCircle_1.results()[1].setName("SketchCircle_2_2")
100 SketchCircle_1.setAuxiliary(True)
101 SketchArc_3 = Sketch_1.addArc(2.333185352801025, 5.209035955269018, 9.336485740095949, 23.71540254943274, 4.745637396078732, -14.43051332599376, True)
102 SketchArc_3.setName("SketchArc_4")
103 SketchArc_3.result().setName("SketchArc_4")
104 SketchArc_3.results()[1].setName("SketchArc_4_2")
105 SketchConstraintCoincidence_15 = Sketch_1.setCoincident(SketchArc_3.center(), SketchCircle_1.center())
106 SketchConstraintCoincidence_15.setName("SketchConstraintCoincidence_17")
107 SketchPoint_1 = Sketch_1.addPoint(-30.48122876352205, 16.49385395867538)
108 SketchConstraintCoincidence_16 = Sketch_1.setCoincident(SketchPoint_1.coordinates(), SketchCircle_1.results()[1])
109 SketchConstraintCoincidence_16.setName("SketchConstraintCoincidence_18")
110 SketchPoint_2 = Sketch_1.addPoint(33.38569114717736, 20.69692719513029)
111 SketchConstraintCoincidence_17 = Sketch_1.setCoincident(SketchPoint_2.coordinates(), SketchCircle_1.results()[1])
112 SketchConstraintCoincidence_17.setName("SketchConstraintCoincidence_19")
113 SketchPoint_3 = Sketch_1.addPoint(4.745637396078732, -14.43051332599376)
114 SketchConstraintCoincidence_18 = Sketch_1.setCoincident(SketchPoint_3.coordinates(), SketchArc_3.endPoint())
115 SketchConstraintCoincidence_18.setName("SketchConstraintCoincidence_20")
116 SketchPoint_4 = Sketch_1.addPoint(9.336485740095949, 23.71540254943274)
117 SketchConstraintCoincidence_19 = Sketch_1.setCoincident(SketchPoint_4.coordinates(), SketchArc_3.startPoint())
118 SketchConstraintCoincidence_19.setName("SketchConstraintCoincidence_21")
119 SketchArc_4 = Sketch_1.addArc(2.333185352801027, 5.209035955269019, 9.336485740095949, 23.71540254943274, 4.745637396078732, -14.43051332599376, False)
120 SketchArc_4.setName("SketchArc_3")
121 SketchArc_4.result().setName("SketchArc_3")
122 SketchArc_4.results()[1].setName("SketchArc_3_2")
123 SketchConstraintCoincidence_20 = Sketch_1.setCoincident(SketchArc_3.endPoint(), SketchArc_4.endPoint())
124 SketchConstraintCoincidence_20.setName("SketchConstraintCoincidence_22")
125 SketchConstraintCoincidence_21 = Sketch_1.setCoincident(SketchArc_3.startPoint(), SketchArc_4.startPoint())
126 SketchConstraintCoincidence_21.setName("SketchConstraintCoincidence_23")
127 SketchConstraintTangent_5 = Sketch_1.setTangent(SketchArc_4.results()[1], SketchArc_3.results()[1])
128 SketchConstraintCoincidence_22 = Sketch_1.setCoincident(SketchArc_4.endPoint(), SketchPoint_3.coordinates())
129 SketchConstraintCoincidence_22.setName("SketchConstraintCoincidence_24")
130 SketchConstraintCoincidence_23 = Sketch_1.setCoincident(SketchArc_4.startPoint(), SketchPoint_4.coordinates())
131 SketchConstraintCoincidence_23.setName("SketchConstraintCoincidence_25")
132 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_7.result(), "a/2")
133 model.do()
134 Sketch_1.result().setColor(85, 255, 0)
135 Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
136 SketchPoint_5 = Sketch_2.addPoint(27.94100551732842, 60.77708330244815)
137 SketchPoint_5.setAuxiliary(True)
138 SketchArc_5 = Sketch_2.addArc(29.50596093963414, 45.389553391128, 31.03624924456759, 29.99853718200911, 27.94100551732842, 60.77708330244815, True)
139 SketchArc_5.setName("SketchArc_6")
140 SketchArc_5.result().setName("SketchArc_6")
141 SketchArc_5.results()[1].setName("SketchArc_6_2")
142 SketchConstraintCoincidence_24 = Sketch_2.setCoincident(SketchPoint_5.coordinates(), SketchArc_5.endPoint())
143 SketchConstraintCoincidence_24.setName("SketchConstraintCoincidence_26")
144 SketchPoint_6 = Sketch_2.addPoint(31.03624924456759, 29.99853718200911)
145 SketchPoint_6.setAuxiliary(True)
146 SketchConstraintCoincidence_25 = Sketch_2.setCoincident(SketchPoint_6.coordinates(), SketchArc_5.startPoint())
147 SketchConstraintCoincidence_25.setName("SketchConstraintCoincidence_27")
148 SketchArc_6 = Sketch_2.addArc(29.50596093963414, 45.389553391128, 31.03624924456759, 29.99853718200911, 27.94100551732842, 60.77708330244815, False)
149 SketchArc_6.setName("SketchArc_5")
150 SketchArc_6.result().setName("SketchArc_5")
151 SketchArc_6.results()[1].setName("SketchArc_5_2")
152 SketchConstraintCoincidence_26 = Sketch_2.setCoincident(SketchArc_5.endPoint(), SketchArc_6.endPoint())
153 SketchConstraintCoincidence_26.setName("SketchConstraintCoincidence_28")
154 SketchConstraintCoincidence_27 = Sketch_2.setCoincident(SketchArc_5.startPoint(), SketchArc_6.startPoint())
155 SketchConstraintCoincidence_27.setName("SketchConstraintCoincidence_29")
156 SketchConstraintTangent_6 = Sketch_2.setTangent(SketchArc_6.results()[1], SketchArc_5.results()[1])
157 SketchConstraintCoincidence_28 = Sketch_2.setCoincident(SketchArc_6.startPoint(), SketchPoint_6.coordinates())
158 SketchConstraintCoincidence_28.setName("SketchConstraintCoincidence_30")
159 SketchConstraintCoincidence_29 = Sketch_2.setCoincident(SketchArc_6.endPoint(), SketchPoint_5.coordinates())
160 SketchConstraintCoincidence_29.setName("SketchConstraintCoincidence_31")
161 SketchLine_10 = Sketch_2.addLine(28.46272147483239, 70.73361683339229, 38.77955906494226, 70.73651278326217)
162 SketchLine_10.setName("SketchLine_11")
163 SketchLine_10.result().setName("SketchLine_11")
164 SketchLine_10.setAuxiliary(True)
165 SketchPoint_7 = Sketch_2.addPoint(28.46272147483239, 70.73361683339229)
166 SketchConstraintCoincidence_30 = Sketch_2.setCoincident(SketchPoint_7.coordinates(), SketchLine_10.startPoint())
167 SketchConstraintCoincidence_30.setName("SketchConstraintCoincidence_32")
168 SketchLine_11 = Sketch_2.addLine(16.42641095303756, 70.73023822521078, 28.46272147483239, 70.73361683339229)
169 SketchLine_11.setName("SketchLine_12")
170 SketchLine_11.result().setName("SketchLine_12")
171 SketchConstraintCoincidence_31 = Sketch_2.setCoincident(SketchLine_11.endPoint(), SketchLine_10.startPoint())
172 SketchConstraintCoincidence_31.setName("SketchConstraintCoincidence_33")
173 SketchConstraintParallel_2 = Sketch_2.setParallel(SketchLine_10.result(), SketchLine_11.result())
174 SketchConstraintCoincidence_32 = Sketch_2.setCoincident(SketchLine_11.endPoint(), SketchPoint_7.coordinates())
175 SketchConstraintCoincidence_32.setName("SketchConstraintCoincidence_34")
176 model.do()
177 Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_8r-SketchLine_7r-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchArc_2_2f-SketchLine_10r-SketchArc_1_2f-SketchLine_9r-SketchArc_3_2r-SketchArc_4_2r")], model.selection("EDGE", "Sketch_2/SketchLine_12"), 360, 0)
178 Partition_1 = model.addPartition(Part_1_doc, [model.selection("FACE", "PartSet/Plane_4"), model.selection("SOLID", "Revolution_1_1")])
179 Recover_1 = model.addRecover(Part_1_doc, Partition_1, [Revolution_1.result()])
180 Plane_5 = model.addPlane(Part_1_doc, model.selection("EDGE", "PartSet/Axis_4"), model.selection("VERTEX", "PartSet/Point_2"), True)
181 Face_1_objects = [model.selection("EDGE", "Sketch_1/SketchArc_2_2"), model.selection("EDGE", "Sketch_1/SketchLine_4"), model.selection("EDGE", "Sketch_1/SketchLine_5"), model.selection("EDGE", "Sketch_1/SketchLine_6"), model.selection("EDGE", "Sketch_1/SketchLine_7"), model.selection("EDGE", "Sketch_1/SketchLine_8"), model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SketchLine_2")]
182 Face_1 = model.addFace(Part_1_doc, Face_1_objects)
183 Intersection_1 = model.addIntersection(Part_1_doc, [model.selection("SOLID", "Recover_1_1"), model.selection("FACE", "Face_1_1")])
184 Group_1_objects = [
185 model.selection("VERTEX", "Intersection_1_1_3/Modified_Vertex&Sketch_1/SketchLine_1_StartVertex&Sketch_1/SketchLine_8_EndVertex"),
186 model.selection("VERTEX", "[Intersection_1_1_1/Intersection_1_1_1]e[weak_name_2]"),
187 model.selection("VERTEX", "Intersection_1_1_9/Modified_Vertex&Sketch_1/SketchLine_5_StartVertex&Sketch_1/SketchLine_4_EndVertex"),
188 model.selection("VERTEX", "Intersection_1_1_7/Modified_Vertex&Sketch_1/SketchLine_7_StartVertex&Sketch_1/SketchLine_6_EndVertex"),
189 model.selection("VERTEX", "[Intersection_1_1_4/Intersection_1_1_4]e[weak_name_2]"),
190 model.selection("VERTEX", "[Intersection_1_1_1/Intersection_1_1_1]e[weak_name_1]"),
191 model.selection("VERTEX", "Intersection_1_1_2/Modified_Vertex&Sketch_1/SketchLine_2_EndVertex&Sketch_1/SketchArc_2_2_EndVertex"),
192 model.selection("VERTEX", "[Intersection_1_1_4/Intersection_1_1_4]e[weak_name_1]"),
193 model.selection("VERTEX", "Intersection_1_1_6/Modified_Vertex&Sketch_1/SketchLine_8_StartVertex&Sketch_1/SketchLine_7_EndVertex"),
194 model.selection("VERTEX", "Intersection_1_1_10/Modified_Vertex&Sketch_1/SketchLine_4_StartVertex&Sketch_1/SketchArc_2_2_StartVertex"),
195 model.selection("VERTEX", "Intersection_1_1_8/Modified_Vertex&Sketch_1/SketchLine_6_StartVertex&Sketch_1/SketchLine_5_EndVertex")]
196
197 Group_1 = model.addGroup(Part_1_doc, Group_1_objects)
198 Group_2_objects = [model.selection("EDGE", "Intersection_1_1_7"), model.selection("EDGE", "Intersection_1_1_6"), model.selection("EDGE", "Intersection_1_1_3"), model.selection("EDGE", "Intersection_1_1_11"), model.selection("EDGE", "Intersection_1_1_5"), model.selection("EDGE", "Intersection_1_1_1"), model.selection("EDGE", "Intersection_1_1_4"), model.selection("EDGE", "Intersection_1_1_2"), model.selection("EDGE", "Intersection_1_1_10"), model.selection("EDGE", "Intersection_1_1_9"), model.selection("EDGE", "Intersection_1_1_8")]
199 Group_2 = model.addGroup(Part_1_doc, Group_2_objects)
200 model.do()
201 model.end()
202
203 aGroupFeature = Group_1.feature()
204 aSelectionList = aGroupFeature.selectionList("group_list")
205 assert(aSelectionList.size() == 11)
206 for index in range(0, aSelectionList.size()):
207   attrSelection = aSelectionList.value(index)
208   shape = attrSelection.value()
209   name = attrSelection.namingName()
210   assert(shape.isVertex())
211   assert(name)
212
213 aGroupFeature = Group_2.feature()
214 aSelectionList = aGroupFeature.selectionList("group_list")
215 assert(aSelectionList.size() == 11)
216 for index in range(0, aSelectionList.size()):
217   attrSelection = aSelectionList.value(index)
218   shape = attrSelection.value()
219   name = attrSelection.namingName()
220   assert(shape.isEdge())
221   assert(name)
222
223 assert(model.checkPythonDump())