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, "g", "5")
27 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
28 SketchLine_1 = Sketch_1.addLine(0, 200, 0, 0)
29 SketchLine_2 = Sketch_1.addLine(0, 0, 250, 0)
30 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
31 SketchLine_3 = Sketch_1.addLine(500, 0, 500, 200)
32 SketchArc_1 = Sketch_1.addArc(250, 200.000000000003, 0, 200, 500, 200, True)
33 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchArc_1.startPoint())
34 SketchConstraintCoincidence_2.setName("SketchConstraintCoincidence_3")
35 SketchConstraintTangent_1 = Sketch_1.setTangent(SketchLine_1.result(), SketchArc_1.results()[1])
36 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.result(), SketchArc_1.endPoint())
37 SketchConstraintCoincidence_3.setName("SketchConstraintCoincidence_4")
38 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_3.endPoint())
39 SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_5")
40 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_2.result())
41 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_1.result())
42 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_3.result())
43 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 250)
44 SketchPoint_1 = Sketch_1.addPoint(model.selection("VERTEX", "PartSet/Origin"))
45 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchPoint_1.coordinates())
46 SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_6")
47 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_3.result(), 200)
48 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_1.result(), 200)
49 SketchArc_2 = Sketch_1.addArc(250, 0, 1.232595164407831e-32, 0, 500, 0, False)
50 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchArc_2.center())
51 SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_7")
52 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchArc_2.startPoint())
53 SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_8")
54 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_2.result(), SketchArc_2.endPoint())
55 SketchConstraintCoincidence_8.setName("SketchConstraintCoincidence_9")
56 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_2.result(), SketchArc_2.endPoint())
57 SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_10")
58 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchArc_2.results()[1], SketchArc_2.startPoint())
59 SketchConstraintCoincidence_10.setName("SketchConstraintCoincidence_11")
60 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_3.startPoint())
61 SketchConstraintCoincidence_11.setName("SketchConstraintCoincidence_12")
63 Sketch_1.setName("toto")
64 Sketch_1.result().setName("tutu")
65 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "tutu/Face-SketchLine_1r-SketchArc_2_2f-SketchLine_3f-SketchArc_1_2f")], model.selection(), 10, 0)
66 Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "tutu/SketchLine_2")])
67 Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], model.selection("EDGE", "PartSet/OZ"), 100, 0)
68 Group_1 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "[Extrusion_2_1/Generated_Edge&tutu/SketchLine_2_StartVertex]e[Extrusion_2_1/To_Edge]e"), model.selection("VERTEX", "[Extrusion_2_1/Generated_Edge&tutu/SketchLine_2_EndVertex]e[Extrusion_2_1/To_Edge]e")])
72 # check that resulting group selection is valid
73 from ModelAPI import *
74 aFactory = ModelAPI_Session.get().validators()
75 assert(aFactory.validate(Group_1.feature()))
76 assert(Group_1.groupList().size() == 2)
77 assert(Group_1.groupList().value(0).value().shapeTypeStr() == "VERTEX")
78 assert(Group_1.groupList().value(1).value().shapeTypeStr() == "VERTEX")
80 assert(model.checkPythonDump())