]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelAPI/Test/Test2170.py
Salome HOME
a814c829e37f294f6e1190e4b829813bb2d2b2cd
[modules/shaper.git] / src / ModelAPI / Test / Test2170.py
1 # Copyright (C) 2014-2019  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 # -*- coding: utf-8 -*-
21
22 from salome.shaper import model
23
24 model.begin()
25 partSet = model.moduleDocument()
26 Part_1 = model.addPart(partSet)
27 Part_1_doc = Part_1.document()
28 model.addParameter(Part_1_doc, "g", "5")
29 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
30 SketchLine_1 = Sketch_1.addLine(0, 200, 0, 0)
31 SketchLine_2 = Sketch_1.addLine(0, 0, 250, 0)
32 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
33 SketchLine_3 = Sketch_1.addLine(500, 0, 500, 200)
34 SketchArc_1 = Sketch_1.addArc(250, 200.000000000003, 0, 200, 500, 200, True)
35 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchArc_1.startPoint())
36 SketchConstraintCoincidence_2.setName("SketchConstraintCoincidence_3")
37 SketchConstraintTangent_1 = Sketch_1.setTangent(SketchLine_1.result(), SketchArc_1.results()[1])
38 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.result(), SketchArc_1.endPoint())
39 SketchConstraintCoincidence_3.setName("SketchConstraintCoincidence_4")
40 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_3.endPoint())
41 SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_5")
42 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_2.result())
43 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_1.result())
44 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_3.result())
45 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 250)
46 SketchPoint_1 = Sketch_1.addPoint(model.selection("VERTEX", "PartSet/Origin"))
47 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchPoint_1.coordinates())
48 SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_6")
49 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_3.result(), 200)
50 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_1.result(), 200)
51 SketchArc_2 = Sketch_1.addArc(250, 0, 1.232595164407831e-32, 0, 500, 0, False)
52 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchArc_2.center())
53 SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_7")
54 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchArc_2.startPoint())
55 SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_8")
56 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_2.result(), SketchArc_2.endPoint())
57 SketchConstraintCoincidence_8.setName("SketchConstraintCoincidence_9")
58 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_2.result(), SketchArc_2.endPoint())
59 SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_10")
60 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchArc_2.results()[1], SketchArc_2.startPoint())
61 SketchConstraintCoincidence_10.setName("SketchConstraintCoincidence_11")
62 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_3.startPoint())
63 SketchConstraintCoincidence_11.setName("SketchConstraintCoincidence_12")
64 model.do()
65 Sketch_1.setName("toto")
66 Sketch_1.result().setName("tutu")
67 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)
68 Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "tutu/SketchLine_2")])
69 Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], model.selection("EDGE", "PartSet/OZ"), 100, 0)
70 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")])
71 model.do()
72 model.end()
73
74 # check that resulting group selection is valid
75 from ModelAPI import *
76 aFactory = ModelAPI_Session.get().validators()
77 assert(aFactory.validate(Group_1.feature()))
78 assert(Group_1.groupList().size() == 2)
79 assert(Group_1.groupList().value(0).value().shapeTypeStr() == "VERTEX")
80 assert(Group_1.groupList().value(1).value().shapeTypeStr() == "VERTEX")
81
82 assert(model.checkPythonDump())