1 # Copyright (C) 2014-2020 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 email : webmaster.salome@opencascade.com
20 from salome.shaper import model
23 partSet = model.moduleDocument()
24 Part_1 = model.addPart(partSet)
25 Part_1_doc = Part_1.document()
26 model.addParameter(Part_1_doc, "h", "100")
27 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
28 SketchLine_1 = Sketch_1.addLine(0, 0, 0, 50)
29 SketchLine_2 = Sketch_1.addLine(0, 50, 50, 50)
30 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
31 SketchLine_3 = Sketch_1.addLine(50, 50, 50, 0)
32 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
33 SketchLine_4 = Sketch_1.addLine(50, 0, 0, 0)
34 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
35 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
36 SketchConstraintRigid_1 = Sketch_1.setFixed(SketchLine_1.startPoint())
37 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_1.result())
38 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_4.result(), 50)
39 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_1.result(), 50)
40 SketchConstraintParallel_1 = Sketch_1.setParallel(SketchLine_1.result(), SketchLine_3.result())
41 SketchConstraintParallel_2 = Sketch_1.setParallel(SketchLine_2.result(), SketchLine_4.result())
42 SketchConstraintPerpendicular_1 = Sketch_1.setPerpendicular(SketchLine_1.result(), SketchLine_4.result())
44 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), 50, 0)
45 Sketch_2 = model.addSketch(Part_1_doc, model.standardPlane("YOZ"))
46 SketchLine_5 = Sketch_2.addLine(10, 21.9014765990379, 0, 21.9014765990379)
47 SketchLine_5.setName("SketchLine_9")
48 SketchLine_5.result().setName("SketchLine_9")
49 SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "PartSet/OZ"), False)
50 SketchLine_6 = SketchProjection_1.createdFeature()
51 SketchLine_6.setName("SketchLine_10")
52 SketchLine_6.result().setName("SketchLine_10")
53 SketchConstraintCoincidence_5 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.result())
54 SketchLine_7 = Sketch_2.addLine(0, 21.9014765990379, 0, 31.9014765990379)
55 SketchLine_7.setName("SketchLine_11")
56 SketchLine_7.result().setName("SketchLine_11")
57 SketchLine_8 = Sketch_2.addLine(0, 31.9014765990379, 10, 31.9014765990379)
58 SketchLine_8.setName("SketchLine_12")
59 SketchLine_8.result().setName("SketchLine_12")
60 SketchLine_9 = Sketch_2.addLine(10, 31.9014765990379, 10, 21.9014765990379)
61 SketchLine_9.setName("SketchLine_13")
62 SketchLine_9.result().setName("SketchLine_13")
63 SketchConstraintCoincidence_6 = Sketch_2.setCoincident(SketchLine_9.endPoint(), SketchLine_5.startPoint())
64 SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_7.startPoint())
65 SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
66 SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_8.endPoint(), SketchLine_9.startPoint())
67 SketchConstraintHorizontal_1 = Sketch_2.setHorizontal(SketchLine_5.result())
68 SketchConstraintVertical_2 = Sketch_2.setVertical(SketchLine_7.result())
69 SketchConstraintHorizontal_2 = Sketch_2.setHorizontal(SketchLine_8.result())
70 SketchConstraintVertical_3 = Sketch_2.setVertical(SketchLine_9.result())
71 SketchConstraintLength_3 = Sketch_2.setLength(SketchLine_9.result(), 10)
72 SketchConstraintLength_4 = Sketch_2.setLength(SketchLine_8.result(), 10)
74 Sketch_2.setName("Sketch_3")
75 Sketch_2.result().setName("Sketch_3")
76 ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_3/Face-SketchLine_13r-SketchLine_12r-SketchLine_11r-SketchLine_9r_wire")], model.selection(), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3"), 0, model.selection(), 0, [model.selection("SOLID", "Extrusion_1_1")])
77 Sketch_3 = model.addSketch(Part_1_doc, model.standardPlane("XOY"))
78 SketchLine_10 = Sketch_3.addLine(29.60939424565112, 0, 19.60939424565112, 0)
79 SketchLine_10.setName("SketchLine_14")
80 SketchLine_10.result().setName("SketchLine_14")
81 SketchProjection_2 = Sketch_3.addProjection(model.selection("EDGE", "PartSet/OX"), False)
82 SketchLine_11 = SketchProjection_2.createdFeature()
83 SketchLine_11.setName("SketchLine_15")
84 SketchLine_11.result().setName("SketchLine_15")
85 SketchConstraintCoincidence_10 = Sketch_3.setCoincident(SketchLine_10.endPoint(), SketchLine_11.result())
86 SketchLine_12 = Sketch_3.addLine(19.60939424565112, 0, 19.60939424565112, 5)
87 SketchLine_12.setName("SketchLine_16")
88 SketchLine_12.result().setName("SketchLine_16")
89 SketchLine_13 = Sketch_3.addLine(19.60939424565112, 5, 29.60939424565112, 5)
90 SketchLine_13.setName("SketchLine_17")
91 SketchLine_13.result().setName("SketchLine_17")
92 SketchLine_14 = Sketch_3.addLine(29.60939424565112, 5, 29.60939424565112, 0)
93 SketchLine_14.setName("SketchLine_18")
94 SketchLine_14.result().setName("SketchLine_18")
95 SketchConstraintCoincidence_11 = Sketch_3.setCoincident(SketchLine_14.endPoint(), SketchLine_10.startPoint())
96 SketchConstraintCoincidence_12 = Sketch_3.setCoincident(SketchLine_10.endPoint(), SketchLine_12.startPoint())
97 SketchConstraintCoincidence_13 = Sketch_3.setCoincident(SketchLine_12.endPoint(), SketchLine_13.startPoint())
98 SketchConstraintCoincidence_14 = Sketch_3.setCoincident(SketchLine_13.endPoint(), SketchLine_14.startPoint())
99 SketchConstraintHorizontal_3 = Sketch_3.setHorizontal(SketchLine_10.result())
100 SketchConstraintVertical_4 = Sketch_3.setVertical(SketchLine_12.result())
101 SketchConstraintHorizontal_4 = Sketch_3.setHorizontal(SketchLine_13.result())
102 SketchConstraintVertical_5 = Sketch_3.setVertical(SketchLine_14.result())
103 SketchConstraintLength_5 = Sketch_3.setLength(SketchLine_12.result(), 5)
104 SketchConstraintLength_6 = Sketch_3.setLength(SketchLine_13.result(), 10)
106 Sketch_3.setName("Sketch_4")
107 Sketch_3.result().setName("Sketch_4")
108 ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("COMPOUND", "Sketch_4")], model.selection(), "h", 0, [model.selection("SOLID", "ExtrusionCut_1_1")])
109 Fillet_1_objects = [model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face][(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)]"), model.selection("EDGE", "[(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)][ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face]"), model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2][ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face]"), model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_2]"), model.selection("EDGE", "[(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_9)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)][ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face]"), model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face][(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_9)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)]"), model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3]"), model.selection("EDGE", "[ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1]"), model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3][ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face]"), model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1][ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face]"), model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3][(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)]"), model.selection("EDGE", "[(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_9)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3]"), model.selection("EDGE", "[(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/From_Face)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_9)(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1]"), model.selection("EDGE", "[ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1][(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)]"), model.selection("EDGE", "[(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)][ExtrusionCut_2_1/Generated_Face&Sketch_4/SketchLine_16&weak_name_2]"), model.selection("EDGE", "[(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3)(ExtrusionCut_2_1/Modified_Face&Sketch_3/SketchLine_12)(ExtrusionCut_2_1/Modified_Face&Extrusion_1_1/To_Face)][ExtrusionCut_2_1/Generated_Face&Sketch_4/SketchLine_18&weak_name_2]")]
110 Fillet_1 = model.addFillet(Part_1_doc, Fillet_1_objects, 2)
112 model.selection("FACE", "(Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_14)(Fillet_1_1/MF:Fillet_Face&Sketch_3/SketchLine_12)(Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_15)(Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_1)"),
113 model.selection("FACE", "(Fillet_1_1/MF:Fillet_Face&Sketch_3/SketchLine_12)(Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_11)(Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_16)(Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_2)"),
114 model.selection("FACE", "(Fillet_1_1/MF:Fillet_Face&Sketch_3/SketchLine_9)(Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_13)(Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_6)"),
115 model.selection("FACE", "(Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_5)(Fillet_1_1/MF:Fillet_Face&Sketch_3/SketchLine_9)(Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_12)")
117 Group_1 = model.addGroup(Part_1_doc, Group_1_objects)
118 Group_2 = model.addGroup(Part_1_doc, [model.selection("EDGE", "[Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_9][Fillet_1_1/MF:Fillet_Face&Extrusion_1_1/To_Face]"), model.selection("EDGE", "[Fillet_1_1/MF:Fillet_Face&Sketch_1/SketchLine_3][Fillet_1_1/GF:Fillet&Fillet_1_1/FilletSelected_9]")])
119 Group_3 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "[Fillet_1_1/MF:Fillet_Face&Sketch_3/SketchLine_9][ExtrusionCut_1_1/Generated_Face&Sketch_3/SketchLine_13][Fillet_1_1/MF:Fillet_Face&Sketch_1/SketchLine_3]"), model.selection("VERTEX", "[ExtrusionCut_1_1/Generated_Face&Sketch_3/SketchLine_13][Fillet_1_1/MF:Fillet_Face&Sketch_1/SketchLine_3][Fillet_1_1/MF:Fillet_Face&Sketch_3/SketchLine_12]")])
122 Folder_1 = model.addFolder(Part_1_doc, Sketch_3, ExtrusionCut_2)
123 Folder_1.setName("Box")
124 Folder_2 = model.addFolder(Part_1_doc, Group_1, Group_2)
125 Folder_2.setName("Groups")
127 from GeomAPI import GeomAPI_Shape
130 model.testNbResults(Fillet_1, 1)
131 model.testNbSubResults(Fillet_1, [0])
132 model.testNbSubShapes(Fillet_1, GeomAPI_Shape.SOLID, [1])
133 model.testNbSubShapes(Fillet_1, GeomAPI_Shape.FACE, [38])
134 model.testNbSubShapes(Fillet_1, GeomAPI_Shape.EDGE, [184])
135 model.testNbSubShapes(Fillet_1, GeomAPI_Shape.VERTEX, [368])
136 model.testResultsVolumes(Fillet_1, [117584.019523708775523118674755096])
138 model.checkGroup(Group_1, GeomAPI_Shape.FACE)
139 model.checkGroup(Group_2, GeomAPI_Shape.EDGE)
140 model.checkGroup(Group_3, GeomAPI_Shape.VERTEX)
144 assert(model.checkPythonDump())