]> SALOME platform Git repositories - modules/shaper.git/blob - test.models/stair_with_cycle.py
Salome HOME
Issue #3221: Visual separation for features
[modules/shaper.git] / test.models / stair_with_cycle.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 salome.shaper import model
21
22 model.begin()
23 partSet = model.moduleDocument()
24 Part_1 = model.addPart(partSet)
25 Part_1_doc = Part_1.document()
26 h_marche=18
27 model.addParameter(Part_1_doc, "h_marche", str(h_marche))
28 model.addParameter(Part_1_doc, "angle", "35")
29 nb_marches=25
30 h_totale=nb_marches*(h_marche+1)
31
32 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
33 SketchLine_1 = Sketch_1.addLine(13.86513942972648, 15.13114452817127, 113.484609238901, 23.84671880293715)
34 SketchLine_2 = Sketch_1.addLine(124.230417176185, 14, 124.230417176185, 0)
35 SketchLine_3 = Sketch_1.addLine(model.selection("EDGE", "PartSet/OX"))
36 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.result())
37 SketchConstraintCoincidence_1.setName("SketchConstraintCoincidence_2")
38 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
39 SketchArc_1 = Sketch_1.addArc(15.1889430421138, 0, 0, 0, 13.86513942972648, 15.13114452817127, True)
40 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_3.result(), SketchArc_1.center())
41 SketchConstraintCoincidence_2.setName("SketchConstraintCoincidence_3")
42 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.startPoint(), SketchArc_1.startPoint())
43 SketchConstraintCoincidence_3.setName("SketchConstraintCoincidence_4")
44 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchArc_1.endPoint())
45 SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_5")
46 SketchConstraintTangent_1 = Sketch_1.setTangent(SketchLine_1.result(), SketchArc_1.results()[1])
47 SketchArc_2 = Sketch_1.addArc(114.3460855070856, 14, 124.230417176185, 14, 113.484609238901, 23.84671880293715, False)
48 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchArc_2.startPoint(), SketchLine_2.startPoint())
49 SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_6")
50 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_1.endPoint())
51 SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_7")
52 SketchConstraintTangent_2 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchLine_2.result())
53 SketchConstraintTangent_3 = Sketch_1.setTangent(SketchArc_2.results()[1], SketchLine_1.result())
54 SketchConstraintMirror_1_objects = [SketchArc_1.results()[1], SketchLine_1.result(), SketchArc_2.results()[1], SketchLine_2.result()]
55 SketchConstraintMirror_1 = Sketch_1.addMirror(SketchLine_3.result(), SketchConstraintMirror_1_objects)
56 [SketchArc_3, SketchLine_4, SketchArc_4, SketchLine_5] = SketchConstraintMirror_1.mirrored()
57 SketchConstraintAngle_1 = Sketch_1.setAngleBackward(SketchLine_1.result(), SketchLine_3.result(), 5)
58 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 100)
59 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), 14)
60 model.do()
61 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchArc_1_2f-SketchArc_3_2f-SketchLine_4f-SketchArc_4_2f-SketchLine_5f-SketchLine_2r-SketchArc_2_2f-SketchLine_1r")], model.selection(), 5, 0)
62 Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
63 SketchProjection_1 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchArc_1"), True)
64 SketchPoint_1 = SketchProjection_1.createdFeature()
65 SketchCircle_1 = Sketch_2.addCircle(15.1889430421138, 0, 9.469961851384218)
66 SketchConstraintCoincidence_7 = Sketch_2.setCoincident(SketchPoint_1.result(), SketchCircle_1.center())
67 SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_8")
68 model.do()
69 # 1st step :
70 Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_1_2f")], model.selection(), h_totale, 0)
71 Axis_4 = model.addAxis(Part_1_doc, model.selection("FACE", "Extrusion_2_1/Generated_Face&Sketch_2/SketchCircle_1_2"))
72 model.do()
73 # Cycle : use previous step to get the next one, translated and rotated
74 stairFeature = Extrusion_1
75 # 15 steps now to fille the whole cylinder, but it may be changed
76 for step in range(nb_marches):
77   Translation = model.addTranslation(Part_1_doc, [stairFeature.result()], model.selection("EDGE", "PartSet/OZ"), "h_marche")
78   Recover = model.addRecover(Part_1_doc, Translation, [stairFeature.result()])
79   Rotation = model.addRotation(Part_1_doc, [Translation.result()], model.selection("EDGE", "Axis_1"), "angle")
80   model.do() # next transaction
81   stairFeature = Rotation # store the next step feature to translate/rotate it in the next iteration
82
83 #====================================================================================
84 model.end()
85
86 assert(Part_1_doc.size("Bodies") == nb_marches + 2)
87 model.testResultsVolumes(stairFeature, [23382.6888388])
88
89 assert(model.checkPythonDump())