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