]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelAPI/Test/TestGeomNamingSketchPlane.py
Salome HOME
Merge remote-tracking branch 'remotes/origin/HigherLevelObjectsHistory'
[modules/shaper.git] / src / ModelAPI / Test / TestGeomNamingSketchPlane.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 lenParam = model.addParameter(Part_1_doc, "len", "500")
29 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
30 SketchLine_1 = Sketch_1.addLine(-302.4220649391276, 58.25973730731688, -52.42206493912754, 58.25973730731688)
31 SketchLine_2 = Sketch_1.addLine(-52.42206493912754, 58.25973730731688, -52.42206493912754, -61.38418346467283)
32 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
33 SketchLine_3 = Sketch_1.addLine(-52.42206493912754, -61.38418346467283, 147.5779350608725, -61.38418346467283)
34 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
35 SketchLine_4 = Sketch_1.addLine(147.5779350608725, -61.38418346467283, 147.5779350608725, 58.25973730731685)
36 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
37 SketchLine_5 = Sketch_1.addLine(147.5779350608725, 58.25973730731685, 297.5779350608724, 58.25973730731685)
38 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_5.startPoint())
39 SketchLine_6 = Sketch_1.addLine(297.5779350608724, 58.25973730731685, 297.5779350608724, -192.2459441196271)
40 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
41 SketchLine_7 = Sketch_1.addLine(297.5779350608724, -192.2459441196271, -302.4220649391276, -192.2459441196271)
42 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
43 SketchLine_8 = Sketch_1.addLine(-302.4220649391276, -192.2459441196271, -302.4220649391276, 58.25973730731688)
44 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchLine_7.endPoint(), SketchLine_8.startPoint())
45 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_8.endPoint())
46 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_7.result())
47 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
48 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_8.result())
49 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_2.result())
50 SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_4.result())
51 SketchConstraintVertical_4 = Sketch_1.setVertical(SketchLine_6.result())
52 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_7.result(), 600)
53 SketchConstraintHorizontal_3 = Sketch_1.setHorizontal(SketchLine_1.result())
54 SketchConstraintCollinear_1 = Sketch_1.setCollinear(SketchLine_5.result(), SketchLine_1.result())
55 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_1.result(), 250)
56 SketchConstraintLength_3 = Sketch_1.setLength(SketchLine_3.result(), 200)
57 model.do()
58 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_8r-SketchLine_7r-SketchLine_6r-SketchLine_5r-SketchLine_4r-SketchLine_3r-SketchLine_2r-SketchLine_1r")], model.selection(), 600, 0)
59 Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1"))
60 SketchLine_9 = Sketch_2.addLine(236.9930310780426, -200, -144.601680073095, -200)
61 SketchLine_10 = Sketch_2.addLine(-144.601680073095, -200, -144.601680073095, -500)
62 SketchLine_11 = Sketch_2.addLine(-144.601680073095, -500, 236.9930310780426, -500)
63 SketchLine_12 = Sketch_2.addLine(236.9930310780426, -500, 236.9930310780426, -200)
64 SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_12.endPoint(), SketchLine_9.startPoint())
65 SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchLine_9.endPoint(), SketchLine_10.startPoint())
66 SketchConstraintCoincidence_11 = Sketch_2.setCoincident(SketchLine_10.endPoint(), SketchLine_11.startPoint())
67 SketchConstraintCoincidence_12 = Sketch_2.setCoincident(SketchLine_11.endPoint(), SketchLine_12.startPoint())
68 SketchConstraintHorizontal_4 = Sketch_2.setHorizontal(SketchLine_9.result())
69 SketchConstraintVertical_5 = Sketch_2.setVertical(SketchLine_10.result())
70 SketchConstraintHorizontal_5 = Sketch_2.setHorizontal(SketchLine_11.result())
71 SketchConstraintVertical_6 = Sketch_2.setVertical(SketchLine_12.result())
72 SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/SketchLine_1"), False)
73 SketchLine_13 = SketchProjection_1.createdFeature()
74 SketchConstraintDistance_1 = Sketch_2.setDistance(SketchLine_13.result(), SketchLine_9.endPoint(), 200, True)
75 SketchConstraintDistance_2 = Sketch_2.setDistance(SketchLine_10.endPoint(), SketchLine_13.result(), "len", True)
76 model.do()
77 ExtrusionCut_1 = model.addExtrusionCut(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_9r-SketchLine_10f-SketchLine_11f-SketchLine_12f")], model.selection(), model.selection(), 0, model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_7"), 0, [model.selection("SOLID", "Extrusion_1_1")])
78 Sketch_3 = model.addSketch(Part_1_doc, model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3&weak_name_1"))
79 SketchCircle_1 = Sketch_3.addCircle(27.57793506087247, -80, 42.03963933117138)
80 SketchProjection_2 = Sketch_3.addProjection(model.selection("EDGE", "[Extrusion_1_1/From_Face][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3&weak_name_1]"), False)
81 SketchProjection_2.setName("SketchProjection_3")
82 SketchProjection_2.result().setName("SketchProjection_3")
83 SketchLine_14 = SketchProjection_2.createdFeature()
84 SketchLine_14.setName("SketchLine_15")
85 SketchLine_14.result().setName("SketchLine_15")
86 SketchConstraintDistance_4 = Sketch_3.setDistance(SketchLine_14.result(), SketchCircle_1.center(), 80, True)
87 SketchConstraintDistance_4.setName("SketchConstraintDistance_4")
88 SketchProjection_3 = Sketch_3.addProjection(model.selection("EDGE", "[(ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_1)(Extrusion_1_1/From_Face)(ExtrusionCut_1_1/Generated_Face&Sketch_2/SketchLine_9)][ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_3&weak_name_1]"), False)
89 SketchProjection_3.setName("SketchProjection_4")
90 SketchProjection_3.result().setName("SketchProjection_4")
91 SketchLine_15 = SketchProjection_3.createdFeature()
92 SketchLine_15.setName("SketchLine_16")
93 SketchLine_15.result().setName("SketchLine_16")
94 SketchConstraintDistance_3 = Sketch_3.setDistance(SketchLine_15.result(), SketchCircle_1.center(), 80, True)
95 SketchConstraintDistance_3.setName("SketchConstraintDistance_3")
96 model.do()
97 ExtrusionCut_2 = model.addExtrusionCut(Part_1_doc, [model.selection("WIRE", "Sketch_3/Face-SketchCircle_1_2r_wire")], model.selection(), model.selection(), 0, model.selection("FACE", "ExtrusionCut_1_1/Modified_Face&Sketch_1/SketchLine_7"), 0, [model.selection("SOLID", "ExtrusionCut_1_1")])
98 model.do()
99 # update the sketch 2 to make split of a size of a box
100 lenParam.setValue(700)
101 model.end()
102
103 # check that sketch_3 and extrusion are updated well
104 from ModelAPI import *
105 aFactory = ModelAPI_Session.get().validators()
106 assert(aFactory.validate(ExtrusionCut_2.feature()))