]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelAPI/Test/Test2170.py
Salome HOME
Fixes for the issue #2686
[modules/shaper.git] / src / ModelAPI / Test / Test2170.py
1 ## Copyright (C) 2014-2017  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, "g", "5")
28 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
29 SketchLine_1 = Sketch_1.addLine(0, 200, 0, 0)
30 SketchLine_2 = Sketch_1.addLine(0, 0, 250, 0)
31 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
32 SketchLine_3 = Sketch_1.addLine(500, 0, 500, 200)
33 SketchArc_1 = Sketch_1.addArc(250, 200.000000000003, 0, 200, 500, 200, True)
34 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchArc_1.startPoint())
35 SketchConstraintCoincidence_2.setName("SketchConstraintCoincidence_3")
36 SketchConstraintTangent_1 = Sketch_1.setTangent(SketchLine_1.result(), SketchArc_1.results()[1])
37 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.result(), SketchArc_1.endPoint())
38 SketchConstraintCoincidence_3.setName("SketchConstraintCoincidence_4")
39 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_3.endPoint())
40 SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_5")
41 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_2.result())
42 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_1.result())
43 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_3.result())
44 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 250)
45 SketchPoint_1 = Sketch_1.addPoint(model.selection("VERTEX", "PartSet/Origin"))
46 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_2.startPoint(), SketchPoint_1.coordinates())
47 SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_6")
48 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_3.result(), 200)
49 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_1.result(), 200)
50 SketchArc_2 = Sketch_1.addArc(250, 0, 1.232595164407831e-032, 0, 500, 0, False)
51 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchArc_2.center())
52 SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_7")
53 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchArc_2.startPoint())
54 SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_8")
55 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_2.result(), SketchArc_2.endPoint())
56 SketchConstraintCoincidence_8.setName("SketchConstraintCoincidence_9")
57 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchLine_2.result(), SketchArc_2.endPoint())
58 SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_10")
59 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchArc_2.results()[1], SketchArc_2.startPoint())
60 SketchConstraintCoincidence_10.setName("SketchConstraintCoincidence_11")
61 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchArc_2.endPoint(), SketchLine_3.startPoint())
62 SketchConstraintCoincidence_11.setName("SketchConstraintCoincidence_12")
63 model.do()
64 Sketch_1.setName("toto")
65 Sketch_1.result().setName("tutu")
66 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "tutu/Face-SketchLine_1f-SketchLine_3f-SketchArc_1_2f-SketchArc_2_2f")], model.selection(), 10, 0)
67 Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "tutu/Edge-SketchLine_2")])
68 Extrusion_2 = model.addExtrusion(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], model.selection("EDGE", "PartSet/OZ"), 100, 0)
69 Group_1 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "Extrusion_2_1/Generated_Edge_2&Extrusion_2_1/To_Edge_1"), model.selection("VERTEX", "Extrusion_2_1/Generated_Edge_1&Extrusion_2_1/To_Edge_1")])
70 model.end()
71
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")
79
80 assert(model.checkPythonDump())