1 # Copyright (C) 2014-2023 CEA, EDF
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 email : webmaster.salome@opencascade.com
22 from ModelAPI import *
24 def assertPoint(aPoint):
25 assert(aPoint is not None)
26 aPointFeature = aPoint.feature()
27 assert(len(aPointFeature.results()) > 0)
28 aPointResult = modelAPI_ResultConstruction(aPointFeature.firstResult())
29 assert(aPointResult is not None)
30 assert(aPointResult.isInfinite())
39 from salome.shaper import model
42 partSet = model.moduleDocument()
45 Part_1 = model.addPart(partSet)
46 Part_1_doc = Part_1.document()
49 Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
52 SketchLine_1 = Sketch_1.addLine(0, 0, 0.5, 1.3)
56 Edge_1 = model.addEdge(Part_1_doc, [model.selection("COMPOUND", "Sketch_1")], False)
59 LinearCopy_1 = model.addMultiTranslation(Part_1_doc, [model.selection("EDGE", "Edge_1_1")], model.selection("EDGE", "PartSet/OX"), 4, 5, keepSubResults = True)
62 Plane_4 = model.addPlane(Part_1_doc, model.selection("EDGE", "Sketch_1/SketchLine_1"), model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex"), True)
63 Plane_4.setName("Plane_2")
64 Plane_4.result().setName("Plane_2")
65 Plane_4.result().setTransparency(0.6)
68 Plane_5 = model.addPlane(Part_1_doc, model.selection("FACE", "Plane_2"), 1, False)
69 Plane_5.setName("Plane_3")
70 Plane_5.result().setName("Plane_3")
71 Plane_5.result().setTransparency(0.6)
74 Plane_6 = model.addPlane(Part_1_doc, model.selection("EDGE", "LinearCopy_1_1_2"), model.selection("VERTEX", "LinearCopy_1_1_2/MV:Translated&Sketch_1/SketchLine_1_EndVertex"), True)
75 Plane_6.setName("Plane_4")
76 Plane_6.result().setName("Plane_4")
77 Plane_6.result().setTransparency(0.6)
80 Plane_7 = model.addPlane(Part_1_doc, model.selection("FACE", "Plane_4"), 1, False)
81 Plane_7.setName("Plane_5")
82 Plane_7.result().setName("Plane_5")
83 Plane_7.result().setTransparency(0.6)
86 Plane_8 = model.addPlane(Part_1_doc, model.selection("EDGE", "LinearCopy_1_1_3"), model.selection("VERTEX", "LinearCopy_1_1_3/MV:Translated&Sketch_1/SketchLine_1_EndVertex"), True)
87 Plane_8.setName("Plane_6")
88 Plane_8.result().setName("Plane_6")
89 Plane_8.result().setTransparency(0.6)
92 Plane_9 = model.addPlane(Part_1_doc, model.selection("FACE", "Plane_6"), 1, False)
93 Plane_9.setName("Plane_7")
94 Plane_9.result().setName("Plane_7")
95 Plane_9.result().setTransparency(0.6)
97 ### Create Point (by coordinates)
98 Point_1 = model.addPoint(Part_1_doc, 16, 0.5, 1.3)
100 ### Create Point (by position on edge)
101 Point_2 = model.addPoint(Part_1_doc, model.selection("EDGE", "LinearCopy_1_1_4"), 2.5, False, False)
103 ### Create Point (by projection of point on plane)
104 Point_3 = model.addPoint(Part_1_doc, model.selection("VERTEX", "LinearCopy_1_1_3/MV:Translated&Sketch_1/SketchLine_1_EndVertex"), model.selection("FACE", "Plane_7"))
106 ### Create Point (by intersection of axis and plane)
107 Point_4 = model.addPoint(Part_1_doc, model.selection("EDGE", "LinearCopy_1_1_2"), model.selection("FACE", "Plane_5"))
110 Sketch_2 = model.addSketch(Part_1_doc, model.selection("FACE", "Plane_2"))
112 ### Create SketchProjection
113 SketchProjection_1 = Sketch_2.addProjection(model.selection("VERTEX", "Sketch_1/SketchLine_1_EndVertex"), False)
114 SketchPoint_1 = SketchProjection_1.createdFeature()
116 ### Create SketchCircle
117 SketchCircle_1 = Sketch_2.addCircle(0, 0, 0.6)
118 Sketch_2.setCoincident(SketchPoint_1.result(), SketchCircle_1.center())
119 Sketch_2.setRadius(SketchCircle_1.results()[1], 0.6)
123 Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("FACE", "Sketch_2/Face-SketchCircle_1_2f")], model.selection(), model.selection("FACE", "Plane_3"), 0, model.selection(), 0, "Faces|Wires")
124 Extrusion_1.result().setTransparency(0.6)
126 ### Create Point (by center of gravity)
127 Point_5 = model.addPoint(Part_1_doc, model.selection("SOLID", "Extrusion_1_1"))
130 Sphere_1 = model.addSphere(Part_1_doc, model.selection("VERTEX", "Point_1"), 0.8)
133 Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Point_2"), model.selection("EDGE", "LinearCopy_1_1_2"), 0.8, 1)
136 Torus_1 = model.addTorus(Part_1_doc, model.selection("VERTEX", "Point_3"), model.selection("EDGE", "LinearCopy_1_1_3"), 0.8, 0.25)
139 Cone_1 = model.addCone(Part_1_doc, model.selection("VERTEX", "Point_4"), model.selection("EDGE", "LinearCopy_1_1_4"), 0.8, 0.3, 1)
142 Sphere_2 = model.addSphere(Part_1_doc, model.selection("VERTEX", "Point_5"), 0.8)