Salome HOME
updated copyright message
[modules/shaper.git] / src / SketchPlugin / Test / Test3019.py
1 # Copyright (C) 2019-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
20 """
21     Test3019.py
22     Test case for issue #3019 "Error when load python script"
23 """
24
25 from salome.shaper import model
26 from SketchAPI import *
27 from GeomAPI import *
28
29 model.begin()
30 partSet = model.moduleDocument()
31 Part_1 = model.addPart(partSet)
32 Part_1_doc = Part_1.document()
33 model.addParameter(Part_1_doc, "k", "30")
34 model.addParameter(Part_1_doc, "M", "10")
35 model.addParameter(Part_1_doc, "h", "20")
36 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
37 SketchLine_1 = Sketch_1.addLine(15, -8.660254037843767, 15, 8.660254037843762)
38 SketchLine_2 = Sketch_1.addLine(15, 8.660254037843762, 0, 0)
39 SketchLine_2.setAuxiliary(True)
40 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
41 SketchLine_3 = Sketch_1.addLine(0, 0, 15, -8.660254037843767)
42 SketchLine_3.setAuxiliary(True)
43 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
44 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.endPoint())
45 SketchConstraintEqual_1 = Sketch_1.setEqual(SketchLine_2.result(), SketchLine_1.result())
46 SketchConstraintEqual_2 = Sketch_1.setEqual(SketchLine_3.result(), SketchLine_1.result())
47 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
48 SketchPoint_1 = SketchProjection_1.createdFeature()
49 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchAPI_Point(SketchPoint_1).coordinates(), SketchLine_3.startPoint())
50 SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_1.result())
51 SketchConstraintDistance_1 = Sketch_1.setDistance(SketchLine_3.startPoint(), SketchLine_1.result(), "k/2", True)
52 SketchMultiRotation_1 = Sketch_1.addRotation([SketchLine_1.result()], SketchLine_3.startPoint(), 360, 6, True)
53 [SketchLine_4, SketchLine_5, SketchLine_6, SketchLine_7, SketchLine_8] = SketchMultiRotation_1.rotated()
54 SketchCircle_1 = Sketch_1.addCircle(0, 0, 10)
55 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchCircle_1.results()[1], "M")
56 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchLine_3.startPoint())
57 model.do()
58 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchLine_4f-SketchLine_5f-SketchLine_6f-SketchLine_7f-SketchLine_8f-SketchCircle_1_2r")], model.selection(), "h", 0)
59 Point_2 = model.addPoint(Part_1_doc, "0", "0", "h/2")
60 Sphere_1 = model.addSphere(Part_1_doc, model.selection("VERTEX", "Point_1"), 19.5)
61 Common_1 = model.addCommon(Part_1_doc, [model.selection("SOLID", "Extrusion_1_1"), model.selection("SOLID", "Sphere_1_1")])
62 Folder_1 = model.addFolder(Part_1_doc, Sketch_1, Extrusion_1)
63 Folder_2 = model.addFolder(Part_1_doc, Point_2, Sphere_1)
64 model.end()
65
66 model.testNbResults(Common_1, 1)
67 model.testNbSubResults(Common_1, [0])
68 model.testNbSubShapes(Common_1, GeomAPI_Shape.SOLID, [1])
69 model.testNbSubShapes(Common_1, GeomAPI_Shape.FACE, [21])
70 model.testNbSubShapes(Common_1, GeomAPI_Shape.EDGE, [114])
71 model.testNbSubShapes(Common_1, GeomAPI_Shape.VERTEX, [228])
72 model.testResultsVolumes(Common_1, [9302.86764641653])
73
74 assert(model.checkPythonDump())