1 ## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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.
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.
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
17 ## See http:##www.salome-platform.org/ or
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 from salome.shaper import model
24 partSet = model.moduleDocument()
25 Part_1 = model.addPart(partSet)
26 Part_1_doc = Part_1.document()
27 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
28 SketchLine_1 = Sketch_1.addLine(0, 0, 0, 50)
29 SketchProjection_1 = Sketch_1.addProjection(model.selection("VERTEX", "PartSet/Origin"), False)
30 SketchPoint_1 = SketchProjection_1.createdFeature()
31 SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchPoint_1.result())
32 SketchProjection_2 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OY"), False)
33 SketchLine_2 = SketchProjection_2.createdFeature()
34 SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.result())
35 SketchArc_1 = Sketch_1.addArc(0, 0, 0, 50, 50, 0, True)
36 SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchArc_1.center())
37 SketchLine_3 = Sketch_1.addLine(0, 0, 50, 0)
38 SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_1.startPoint(), SketchLine_3.startPoint())
39 SketchConstraintCoincidence_4.setName("SketchConstraintCoincidence_5")
40 SketchProjection_3 = Sketch_1.addProjection(model.selection("EDGE", "PartSet/OX"), False)
41 SketchLine_4 = SketchProjection_3.createdFeature()
42 SketchConstraintCoincidence_5 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.result())
43 SketchConstraintCoincidence_5.setName("SketchConstraintCoincidence_6")
44 SketchConstraintCoincidence_6 = Sketch_1.setCoincident(SketchArc_1.endPoint(), SketchLine_3.endPoint())
45 SketchConstraintCoincidence_6.setName("SketchConstraintCoincidence_7")
46 SketchConstraintCoincidence_7 = Sketch_1.setCoincident(SketchArc_1.startPoint(), SketchLine_1.endPoint())
47 SketchConstraintCoincidence_7.setName("SketchConstraintCoincidence_8")
48 SketchConstraintRadius_1 = Sketch_1.setRadius(SketchArc_1.results()[1], 50)
50 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchLine_1r-SketchArc_1_2f-SketchLine_3f")], model.selection(), 100, 0)
52 Solid_1_objects = [model.selection("FACE", "Extrusion_1_1/Generated_Face_3")]
53 Solid_1 = model.addSolid(Part_1_doc, Solid_1_objects)
54 # check that resulting build-solid feature is invalid: only one not-closed face is used
55 from ModelAPI import *
56 aFactory = ModelAPI_Session.get().validators()
57 assert(aFactory.validate(Solid_1.feature()) == False)
58 ModelAPI_Session.get().abortOperation()
59 # another try: to make a solid with a face inside
61 Plane_4 = model.addPlane(Part_1_doc, model.selection("FACE", "Extrusion_1_1/To_Face_1"), 70, True)
62 Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_1"))
63 SketchLine_5 = Sketch_2.addLine(14.9039069695087, 8.923908092675951, 26.86805702948195, 11.13714035991706)
64 SketchLine_6 = Sketch_2.addLine(26.86805702948195, 11.13714035991706, 18.50962242738747, 32.13572332177004)
65 SketchConstraintCoincidence_8 = Sketch_2.setCoincident(SketchLine_5.endPoint(), SketchLine_6.startPoint())
66 SketchConstraintCoincidence_8.setName("SketchConstraintCoincidence_9")
67 SketchLine_7 = Sketch_2.addLine(18.50962242738747, 32.13572332177004, 14.9039069695087, 8.923908092675951)
68 SketchConstraintCoincidence_9 = Sketch_2.setCoincident(SketchLine_6.endPoint(), SketchLine_7.startPoint())
69 SketchConstraintCoincidence_9.setName("SketchConstraintCoincidence_10")
70 SketchConstraintCoincidence_10 = Sketch_2.setCoincident(SketchLine_5.startPoint(), SketchLine_7.endPoint())
71 SketchConstraintCoincidence_10.setName("SketchConstraintCoincidence_11")
73 Face_1 = model.addFace(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchLine_5f-SketchLine_6f-SketchLine_7f")])
74 Solid_2_objects = [model.selection("FACE", "Extrusion_1_1/Generated_Face_3"), model.selection("FACE", "Extrusion_1_1/Generated_Face_2"), model.selection("FACE", "Extrusion_1_1/To_Face_1"), model.selection("FACE", "Extrusion_1_1/From_Face_1"), model.selection("FACE", "Extrusion_1_1/Generated_Face_1"), model.selection("FACE", "Face_1_1")]
75 Solid_2 = model.addSolid(Part_1_doc, Solid_2_objects)
78 assert(aFactory.validate(Solid_2.feature()) == False)
80 assert(model.checkPythonDump())