]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModelAPI/Test/Test2413.py
Salome HOME
Fix for #19707 : fatal error gp_Dir() input vector has zero norm when loading python...
[modules/shaper.git] / src / ModelAPI / Test / Test2413.py
1 # Copyright (C) 2014-2020  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 salome.shaper import model
21
22 model.begin()
23 partSet = model.moduleDocument()
24 Part_1 = model.addPart(partSet)
25 Part_1_doc = Part_1.document()
26 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
27 SketchLine_1 = Sketch_1.addLine(0, 0, 0, 50)
28 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
29 SketchPoint_1 = SketchProjection_1.createdFeature()
30 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchPoint_1.result())
31 SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
32 SketchLine_2 = SketchProjection_2.createdFeature()
33 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.result())
34 SketchArc_1 = Sketch_1.addArc(0, 0, 0, 50, 50, 0, True)
35 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchArc_1.center())
36 SketchLine_3 = Sketch_1.addLine(0, 0, 50, 0)
37 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.startPoint())
38 SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_5")
39 SketchProjection_3 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
40 SketchLine_4 = SketchProjection_3.createdFeature()
41 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.result())
42 SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_6")
43 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_3.endPoint())
44 SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_7")
45 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_1.endPoint())
46 SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_8")
47 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 50)
48 model.do()
49 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_3f-SketchArc_1_2f-SketchLine_1r")], model.selection(), 100, 0)
50 model.do()
51 Solid_1_objects = [model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3")]
52 Solid_1 = model.addSolid(Part_1_doc, Solid_1_objects)
53 # check that resulting build-solid feature is invalid: only one not-closed face is used
54 from ModelAPI import *
55 aFactory = ModelAPI_Session.get().validators()
56 assert(aFactory.validate(Solid_1.feature()) == False)
57 ModelAPI_Session.get().abortOperation()
58 # another try: to make a solid with a face inside
59 model.begin()
60 Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face"), 70, True)
61 Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1"))
62 SketchLine_5 = Sketch_2.addLine(14.9039069695087, 8.923908092675951, 26.86805702948195, 11.13714035991706)
63 SketchLine_6 = Sketch_2.addLine(26.86805702948195, 11.13714035991706, 18.50962242738747, 32.13572332177004)
64 SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
65 SketchConstraintCoincidence_8.setName("SketchConstraintCoincidence_9")
66 SketchLine_7 = Sketch_2.addLine(18.50962242738747, 32.13572332177004, 14.9039069695087, 8.923908092675951)
67 SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
68 SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_10")
69 SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchLine_5.startPoint(), SketchLine_7.endPoint())
70 SketchConstraintCoincidence_10.setName("SketchConstraintCoincidence_11")
71 model.do()
72 Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_5r-SketchLine_6f-SketchLine_7f")])
73 Solid_1_objects = [model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3"), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchArc_1_2"), model.selection("FACE", "Extrusion_1_1/To_Face"), model.selection("FACE", "Extrusion_1_1/From_Face"), model.selection("FACE", "Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_1"), model.selection("FACE", "Face_1_1")]
74 Solid_1 = model.addSolid(Part_1_doc, Solid_1_objects)
75 model.do()
76 model.end()
77
78 assert(model.checkPythonDump())