Salome HOME
79f3676991e5fbe88974afda88ce2e50ce0ea19a
[modules/shaper.git] / src / ModelAPI / Test / Test2627.py
1 # Copyright (C) 2014-2023  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 SketchAPI import *
21
22 from salome.shaper import model
23
24 model.begin()
25 partSet = model.moduleDocument()
26 model.addParameter(partSet, "L", "10")
27 model.addParameter(partSet, "H", "8")
28 Part_1 = model.addPart(partSet)
29 Part_1_doc = Part_1.document()
30 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
31 SketchLine_1 = Sketch_1.addLine(10, 0, 0, 0)
32 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
33 SketchPoint_1 = SketchProjection_1.createdFeature()
34 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchPoint_1.result())
35 SketchLine_2 = Sketch_1.addLine(0, 0, 0, 8)
36 SketchLine_3 = Sketch_1.addLine(0, 8, 10, 8)
37 SketchLine_4 = Sketch_1.addLine(10, 8, 10, 0)
38 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
39 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
40 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
41 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
42 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
43 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
44 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
45 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
46 SketchLine_5 = Sketch_1.addLine(2.5, -1.540743955509789e-33, 2.5, 8)
47 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_5.startPoint(), SketchLine_1.result())
48 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_3.result())
49 SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_5.result())
50 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_3.result(), "L")
51 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), "H")
52 SketchConstraintDistanceHorizontal_1 = Sketch_1.setHorizontalDistance(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_5.startPoint(), "L/4.")
53 model.do()
54 Shell_1 = model.addShell(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_5f-SketchLine_3r-SketchLine_2r-SketchLine_1r"), model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_5r-SketchLine_1r")])
55 Group_1 = model.addGroup(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_5f-SketchLine_3r-SketchLine_2r-SketchLine_1r")])
56 Group_1.setName("face_g")
57 Group_1.result().setName("face_g")
58 Group_2 = model.addGroup(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_5r-SketchLine_1r")])
59 Group_2.setName("face_d")
60 Group_2.result().setName("face_d")
61 Group_3 = model.addGroup(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_5f-SketchLine_3r-SketchLine_2r-SketchLine_1r"), model.selection("FACE", "Sketch_1/Face-SketchLine_4r-SketchLine_3r-SketchLine_5r-SketchLine_1r")])
62 Group_3.setName("face_g_d")
63 Group_3.result().setName("face_g_d")
64 Group_4 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Sketch_1/SubEdge_1&Sketch_1/SketchLine_1")])
65 Group_4.setName("ligne_g")
66 Group_4.result().setName("ligne_g")
67 Group_5 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Sketch_1/SubEdge_2&Sketch_1/SketchLine_1")])
68 Group_5.setName("ligne_d")
69 Group_5.result().setName("ligne_d")
70 Group_6 = model.addGroup(Part_1_doc, [model.selection("EDGE", "Sketch_1/SubEdge_1&Sketch_1/SketchLine_1"), model.selection("EDGE", "Sketch_1/SubEdge_2&Sketch_1/SketchLine_1")])
71 Group_6.setName("ligne_g_d")
72 Group_6.result().setName("ligne_g_d")
73 Group_7 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SubVertex_1&Sketch_1/SketchLine_2_EndVertex&Sketch_1/SketchLine_3_StartVertex")])
74 Group_7.setName("coin_g")
75 Group_7.result().setName("coin_g")
76 Group_8 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SubVertex_2&Sketch_1/SketchLine_3_EndVertex&Sketch_1/SketchLine_4_StartVertex")])
77 Group_8.setName("coin_d")
78 Group_8.result().setName("coin_d")
79 Group_9 = model.addGroup(Part_1_doc, [model.selection("VERTEX", "Sketch_1/SubVertex_1&Sketch_1/SketchLine_2_EndVertex&Sketch_1/SketchLine_3_StartVertex"), model.selection("VERTEX", "Sketch_1/SubVertex_2&Sketch_1/SketchLine_3_EndVertex&Sketch_1/SketchLine_4_StartVertex")])
80 Group_9.setName("coins")
81 Group_9.result().setName("coins")
82 model.end()
83
84 # check all groups are correct
85 from ModelAPI import *
86 aFactory = ModelAPI_Session.get().validators()
87 for i in range(Part_1_doc.size("Groups")):
88   GroupFeature = Part_1_doc.feature(objectToResult(Part_1_doc.object("Groups", i)))
89   assert(aFactory.validate(GroupFeature))
90
91 assert(model.checkPythonDump())