Salome HOME
Issue #2358: Ability to put consecutive Features in a folder
[modules/shaper.git] / src / ModelAPI / Test / Test2358_2.py
1 ## Copyright (C) 2018-20xx  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
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 ##
20
21 from salome.shaper import model
22
23 model.begin()
24 partSet = model.moduleDocument()
25 Part_1 = model.addPart(partSet)
26 Part_1_doc = Part_1.document()
27 model.addParameter(Part_1_doc, "h", "100")
28 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
29 SketchLine_1 = Sketch_1.addLine(0, 0, 0, 50)
30 SketchLine_2 = Sketch_1.addLine(0, 50, 50, 50)
31 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
32 SketchLine_3 = Sketch_1.addLine(50, 50, 50, 0)
33 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
34 SketchLine_4 = Sketch_1.addLine(50, 0, 0, 0)
35 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
36 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
37 SketchConstraintRigid_1 = Sketch_1.setFixed(SketchLine_1.startPoint())
38 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_1.result())
39 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_4.result(), 50)
40 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_1.result(), 50)
41 SketchConstraintParallel_1 = Sketch_1.setParallel(SketchLine_1.result(), SketchLine_3.result())
42 SketchConstraintParallel_2 = Sketch_1.setParallel(SketchLine_2.result(), SketchLine_4.result())
43 SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_1.result(), SketchLine_4.result())
44 model.do()
45 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_2r-SketchLine_3r-SketchLine_4r")], model.selection(), 50, 0)
46 Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("YOZ"))
47 SketchLine_5 = Sketch_2.addLine(10, 21.9014765990379, 0, 21.9014765990379)
48 SketchLine_5.setName("SketchLine_9")
49 SketchLine_5.result().setName("SketchLine_9")
50 SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OZ"), False)
51 SketchLine_6 = SketchProjection_1.createdFeature()
52 SketchLine_6.setName("SketchLine_10")
53 SketchLine_6.result().setName("SketchLine_10")
54 SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.result())
55 SketchLine_7 = Sketch_2.addLine(0, 21.9014765990379, 0, 31.9014765990379)
56 SketchLine_7.setName("SketchLine_11")
57 SketchLine_7.result().setName("SketchLine_11")
58 SketchLine_8 = Sketch_2.addLine(0, 31.9014765990379, 10, 31.9014765990379)
59 SketchLine_8.setName("SketchLine_12")
60 SketchLine_8.result().setName("SketchLine_12")
61 SketchLine_9 = Sketch_2.addLine(10, 31.9014765990379, 10, 21.9014765990379)
62 SketchLine_9.setName("SketchLine_13")
63 SketchLine_9.result().setName("SketchLine_13")
64 SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_9.endPoint(), SketchLine_5.startPoint())
65 SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_7.startPoint())
66 SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
67 SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint())
68 SketchConstraintHorizontal_1 = Sketch_2.setHorizontal(SketchLine_5.result())
69 SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_7.result())
70 SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_8.result())
71 SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_9.result())
72 SketchConstraintLength_3 = Sketch_2.setLength(SketchLine_9.result(), 10)
73 SketchConstraintLength_4 = Sketch_2.setLength(SketchLine_8.result(), 10)
74 model.do()
75 Sketch_2.setName("Sketch_3")
76 Sketch_2.result().setName("Sketch_3")
77 ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_3/Wire-SketchLine_9r-SketchLine_11r-SketchLine_12r-SketchLine_13r")], model.selection(), model.selection("FACE", "Extrusion_1_1/Generated_Face_3"), 0, model.selection(), 0, [model.selection("SOLID", "Extrusion_1_1")])
78 Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
79 SketchLine_10 = Sketch_3.addLine(29.60939424565112, 0, 19.60939424565112, 0)
80 SketchLine_10.setName("SketchLine_14")
81 SketchLine_10.result().setName("SketchLine_14")
82 SketchProjection_2 = Sketch_3.addProjection(model.selection("EDGE", "PartSet/OX"), False)
83 SketchLine_11 = SketchProjection_2.createdFeature()
84 SketchLine_11.setName("SketchLine_15")
85 SketchLine_11.result().setName("SketchLine_15")
86 SketchConstraintCoincidence_10 = Sketch_3.setCoincident(SketchLine_10.endPoint(), SketchLine_11.result())
87 SketchLine_12 = Sketch_3.addLine(19.60939424565112, 0, 19.60939424565112, 5)
88 SketchLine_12.setName("SketchLine_16")
89 SketchLine_12.result().setName("SketchLine_16")
90 SketchLine_13 = Sketch_3.addLine(19.60939424565112, 5, 29.60939424565112, 5)
91 SketchLine_13.setName("SketchLine_17")
92 SketchLine_13.result().setName("SketchLine_17")
93 SketchLine_14 = Sketch_3.addLine(29.60939424565112, 5, 29.60939424565112, 0)
94 SketchLine_14.setName("SketchLine_18")
95 SketchLine_14.result().setName("SketchLine_18")
96 SketchConstraintCoincidence_11 = Sketch_3.setCoincident(SketchLine_14.endPoint(), SketchLine_10.startPoint())
97 SketchConstraintCoincidence_12 = Sketch_3.setCoincident(SketchLine_10.endPoint(), SketchLine_12.startPoint())
98 SketchConstraintCoincidence_13 = Sketch_3.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint())
99 SketchConstraintCoincidence_14 = Sketch_3.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint())
100 SketchConstraintHorizontal_3 = Sketch_3.setHorizontal(SketchLine_10.result())
101 SketchConstraintVertical_4 = Sketch_3.setVertical(SketchLine_12.result())
102 SketchConstraintHorizontal_4 = Sketch_3.setHorizontal(SketchLine_13.result())
103 SketchConstraintVertical_5 = Sketch_3.setVertical(SketchLine_14.result())
104 SketchConstraintLength_5 = Sketch_3.setLength(SketchLine_12.result(), 5)
105 SketchConstraintLength_6 = Sketch_3.setLength(SketchLine_13.result(), 10)
106 model.do()
107 Sketch_3.setName("Sketch_4")
108 Sketch_3.result().setName("Sketch_4")
109 ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_4")], model.selection(), "h", 0, [model.selection("SOLID", "ExtrusionCut_1_1")])
110 Fillet_1_objects = [model.selection("EDGE", "ExtrusionCut_2_1/Modfied_3&ExtrusionCut_2_1/Modfied_1divided_f_1"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2&ExtrusionCut_2_1/Modfied_3"), model.selection("EDGE", "Extrusion_1_1/Generated_Face_2&ExtrusionCut_2_1/Modfied_3"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_5&Extrusion_1_1/Generated_Face_2"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_6&ExtrusionCut_2_1/Modfied_5"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_5&ExtrusionCut_2_1/Modfied_1divided_f_2"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_5&ExtrusionCut_1_1/Modfied_2"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_5&ExtrusionCut_1_1/Modfied_1"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_2&ExtrusionCut_2_1/Modfied_3"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_1&ExtrusionCut_2_1/Modfied_3"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_2&ExtrusionCut_2_1/Modfied_2"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_6&ExtrusionCut_1_1/Modfied_2"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_1divided_f_2&ExtrusionCut_1_1/Modfied_1"), model.selection("EDGE", "ExtrusionCut_1_1/Modfied_1&ExtrusionCut_2_1/Modfied_1divided_f_1"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_1divided_f_1&ExtrusionCut_2_1/Modfied_7"), model.selection("EDGE", "ExtrusionCut_2_1/Modfied_2&ExtrusionCut_2_1/Modfied_9")]
111 Fillet_1 = model.addFillet(Part_1_doc, Fillet_1_objects, 2)
112 Group_1_objects = [model.selection("FACE", "Fillet_1_1/Modified_Face_3"), model.selection("FACE", "Fillet_1_1/Modified_Face_5"), model.selection("FACE", "Fillet_1_1/Modified_Face_9"), model.selection("FACE", "Fillet_1_1/Modified_Face_15")]
113 Group_1 = model.addGroup(Part_1_doc, Group_1_objects)
114 Group_2 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Fillet_1_1/Fillet_Face_13&Fillet_1_1/Modified_Face_4"), model.selection("EDGE", "Fillet_1_1/Modified_Face_11&Fillet_1_1/Fillet_Face_13")])
115 Group_3 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "Fillet_1_1/Modified_Face_12&ExtrusionCut_1_1/Modfied_6&Fillet_1_1/Modified_Face_11"), model.selection("VERTEX", "ExtrusionCut_1_1/Modfied_6&Fillet_1_1/Modified_Face_11&Fillet_1_1/Modified_Face_6")])
116 model.do()
117
118 Folder_1 = model.addFolder(Part_1_doc, Sketch_3, ExtrusionCut_2)
119 Folder_1.setName("Box")
120 Folder_2 = model.addFolder(Part_1_doc, Group_1, Group_2)
121 Folder_2.setName("Groups")
122
123 from GeomAPI import GeomAPI_Shape
124
125 # check result shape
126 model.testNbResults(Fillet_1, 1)
127 model.testNbSubResults(Fillet_1, [0])
128 model.testNbSubShapes(Fillet_1, GeomAPI_Shape.SOLID, [1])
129 model.testNbSubShapes(Fillet_1, GeomAPI_Shape.FACE, [38])
130 model.testNbSubShapes(Fillet_1, GeomAPI_Shape.EDGE, [184])
131 model.testNbSubShapes(Fillet_1, GeomAPI_Shape.VERTEX, [368])
132 model.testResultsVolumes(Fillet_1, [117584.019523708775523118674755096])
133 # check groups
134 model.checkGroup(Group_1, GeomAPI_Shape.FACE)
135 model.checkGroup(Group_2, GeomAPI_Shape.EDGE)
136 model.checkGroup(Group_3, GeomAPI_Shape.VERTEX)
137
138 model.end()
139
140 assert(model.checkPythonDump())