Salome HOME
Merge branch 'csgroup_IS2'
[modules/shaper.git] / src / ConnectorAPI / Test / Test18887.py
1 # Copyright (C) 2014-2021  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 import sys
20 import salome
21
22 salome.salome_init()
23 import salome_notebook
24 ###
25 ### SHAPER component
26 ###
27 from SketchAPI import *
28 from salome.shaper import model
29 model.begin()
30 partSet = model.moduleDocument()
31 Part_1 = model.addPart(partSet)
32 Part_1_doc = Part_1.document()
33 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
34 SketchLine_1 = Sketch_1.addLine(30, 0, 0, 0)
35 SketchLine_1.setAuxiliary(True)
36 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
37 SketchPoint_1 = SketchProjection_1.createdFeature()
38 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchPoint_1.result())
39 SketchLine_2 = Sketch_1.addLine(0, 0, 0, 26)
40 SketchLine_2.setAuxiliary(True)
41 SketchLine_3 = Sketch_1.addLine(0, 26, 30, 26)
42 SketchLine_3.setAuxiliary(True)
43 SketchLine_4 = Sketch_1.addLine(30, 26, 30, 0)
44 SketchLine_4.setAuxiliary(True)
45 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
46 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
47 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
48 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
49 SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result())
50 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result())
51 SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result())
52 SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result())
53 SketchConstraintLength_1 = Sketch_1.setLength(SketchLine_1.result(), 30)
54 SketchConstraintLength_2 = Sketch_1.setLength(SketchLine_2.result(), 26)
55 SketchBSplinePeriodic_1 = Sketch_1.addSpline(poles = [(5, 26), (-1.697788041973476e-26, 13), (5, 0), (30, 13)], periodic = True)
56 [SketchPoint_2, SketchPoint_3, SketchPoint_4, SketchPoint_5] = SketchBSplinePeriodic_1.controlPoles(auxiliary = [0, 1, 2, 3])
57 [SketchLine_5, SketchLine_6, SketchLine_7, SketchLine_8] = SketchBSplinePeriodic_1.controlPolygon(auxiliary = [0, 1, 2, 3])
58 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_6).startPoint(), SketchLine_2.result())
59 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_3.result())
60 SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_8")
61 SketchConstraintCoincidence_8 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_7).endPoint(), SketchLine_4.result())
62 SketchConstraintCoincidence_8.setName("SketchConstraintCoincidence_9")
63 SketchConstraintMiddle_1 = Sketch_1.setMiddlePoint(SketchAPI_Line(SketchLine_7).endPoint(), SketchLine_4.result())
64 SketchConstraintCoincidence_9 = Sketch_1.setCoincident(SketchAPI_Line(SketchLine_6).endPoint(), SketchLine_1.result())
65 SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_10")
66 SketchConstraintMiddle_2 = Sketch_1.setMiddlePoint(SketchAPI_Line(SketchLine_6).startPoint(), SketchLine_2.result())
67 SketchLine_9 = Sketch_1.addLine(5, 26, 5, 0)
68 SketchLine_9.setAuxiliary(True)
69 SketchConstraintCoincidence_10 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_2).coordinates(), SketchLine_9.startPoint())
70 SketchConstraintCoincidence_10.setName("SketchConstraintCoincidence_11")
71 SketchConstraintCoincidence_11 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_4).coordinates(), SketchLine_9.endPoint())
72 SketchConstraintCoincidence_11.setName("SketchConstraintCoincidence_12")
73 SketchConstraintVertical_3 = Sketch_1.setVertical(SketchLine_9.result())
74 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchAPI_Line(SketchLine_6).endPoint(), SketchLine_2.result(), 5, True)
75 model.do()
76 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchBSplinePeriodic_1f")], model.selection(), 1, 0)
77 model.end()
78
79 ###
80 ### SHAPERSTUDY component
81 ###
82 model.publishToShaperStudy()
83
84 # from the issue scenario: make fillet and two publications (caused by dump and save)
85 model.begin()
86 Fillet_1 = model.addFillet(Part_1_doc, [model.selection("EDGE", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchBSplinePeriodic_1][Extrusion_1_1/To_Face]")], 0.4999, keepSubResults = True)
87 model.end()
88
89 model.publishToShaperStudy()
90 model.publishToShaperStudy()