Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Complex Objects


Creation of a Prism

1 # Creation of a Prism
2 
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 gg = salome.ImportComponentGUI("GEOM")
9 
10 # create a vertex and a vector
11 p1 = geompy.MakeVertex( 0., 0., 0.)
12 p2 = geompy.MakeVertex( 100., 0., 0.)
13 p3 = geompy.MakeVertex( 100., 100., 0.)
14 p4 = geompy.MakeVertex( 0., 100., 0.)
15 p5 = geompy.MakeVertex( 0., 0., 60.)
16 p6 = geompy.MakeVertex(-100., 0., 0.)
17 p7 = geompy.MakeVertex(-100.,-100., 0.)
18 p8 = geompy.MakeVertex( 0.,-100., 0.)
19 
20 # create a vector from the given components
21 vector = geompy.MakeVectorDXDYDZ(50., 50., 50.)
22 
23 #create vectors from two points
24 vector1_arc1 = geompy.MakeVector(p1, p2)
25 vector2_arc1 = geompy.MakeVector(p1, p4)
26 vector1_arc2 = geompy.MakeVector(p1, p6)
27 vector2_arc2 = geompy.MakeVector(p1, p8)
28 
29 # create arcs from three points
30 arc1 = geompy.MakeArc(p2, p3, p4)
31 arc2 = geompy.MakeArc(p6, p7, p8)
32 
33 # create wires
34 wire1 = geompy.MakeWire([vector1_arc1, arc1, vector2_arc1])
35 wire2 = geompy.MakeWire([vector1_arc2, arc2, vector2_arc2])
36 
37 # create faces
38 isPlanarWanted = 1
39 face1 = geompy.MakeFace(wire1, isPlanarWanted)
40 face2 = geompy.MakeFace(wire2, isPlanarWanted)
41 
42 # create prisms
43 prism1 = geompy.MakePrism(face2, p1, p5)
44 prism2 = geompy.MakePrismVecH(face1, vector, 50)
45 prism3 = geompy.MakePrismVecH2Ways(face1, vector, 50)
46 
47 # add objects in the study
48 id_face1 = geompy.addToStudy(face1,"Face1")
49 id_face2 = geompy.addToStudy(face2,"Face2")
50 id_prism1 = geompy.addToStudy(prism1,"Prism1")
51 id_prism2 = geompy.addToStudy(prism2,"Prism2")
52 id_prism3 = geompy.addToStudy(prism3,"Prism3")
53 
54 # display cylinders
55 gg.createAndDisplayGO(id_face1)
56 gg.setDisplayMode(id_face1,1)
57 gg.createAndDisplayGO(id_face2)
58 gg.setDisplayMode(id_face2,1)
59 gg.createAndDisplayGO(id_prism1)
60 gg.setDisplayMode(id_prism1,1)
61 gg.createAndDisplayGO(id_prism2)
62 gg.setDisplayMode(id_prism2,1)
63 gg.createAndDisplayGO(id_prism3)
64 gg.setDisplayMode(id_prism3,1)

Download this script


Creation of a Revolution

1 # Creation of a Revolution
2 
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 gg = salome.ImportComponentGUI("GEOM")
9 
10 # create a vertex and a vector
11 p1 = geompy.MakeVertex( 10., 10., 10.)
12 p2 = geompy.MakeVertex( 15., 15., 50.)
13 p3 = geompy.MakeVertex( 40., 40., 0.)
14 
15 #create vectors from two points
16 vector1 = geompy.MakeVector(p1, p2)
17 vector2 = geompy.MakeVector(p1, p3)
18 
19 # create a vector from the given components
20 vector3 = geompy.MakeVectorDXDYDZ(-20., -20., 100.)
21 
22 # create a wire
23 wire = geompy.MakeWire([vector1, vector2])
24 
25 # create a revolution
26 revolution = geompy.MakeRevolution(wire, vector3, 2.3)
27 
28 # add objects in the study
29 id_vector3 = geompy.addToStudy(vector3,"Axis")
30 id_wire = geompy.addToStudy(wire,"Wire")
31 id_revolution = geompy.addToStudy(revolution,"Revolution")
32 
33 # display the vector, the wire and the revolution
34 gg.createAndDisplayGO(id_vector3)
35 gg.createAndDisplayGO(id_wire)
36 gg.createAndDisplayGO(id_revolution)
37 gg.setDisplayMode(id_revolution,1)

Download this script


Creation of a Filling

1 # Creation of a Filling
2 
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 gg = salome.ImportComponentGUI("GEOM")
9 
10 mindeg = 2
11 maxdeg = 5
12 tol3d = 0.0001
13 tol2d = 0.0001
14 nbiter = 5
15 
16 # create a vertex and a vector
17 p1 = geompy.MakeVertex( -30., -30., 50.)
18 p2 = geompy.MakeVertex( -60., -60., 30.)
19 p3 = geompy.MakeVertex( -30., -30., 10.)
20 
21 # create an arc from three points
22 arc = geompy.MakeArc(p1, p2, p3)
23 ContoursList = []
24 for i in range(4):
25  S = geompy.MakeTranslation(arc, i * 50., 0., 0.)
26  ContoursList.append(S)
27 
28 compound = geompy.MakeCompound(ContoursList)
29 
30 # create a filling
31 filling = geompy.MakeFilling(compound, mindeg, maxdeg, tol3d, tol2d, nbiter)
32 
33 # add objects in the study
34 id_compound = geompy.addToStudy(compound,"Compound")
35 id_filling = geompy.addToStudy(filling,"Filling")
36 
37 # display the compound and the filling
38 gg.createAndDisplayGO(id_compound)
39 gg.createAndDisplayGO(id_filling)
40 gg.setDisplayMode(id_filling,1)

Download this script


Creation of a Pipe

1 # Creation of a Pipe
2 
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 gg = salome.ImportComponentGUI("GEOM")
9 
10 # create vertices
11 p0 = geompy.MakeVertex(0. , 0. , 0. )
12 px = geompy.MakeVertex(100., 0. , 0. )
13 py = geompy.MakeVertex(0. , 100., 0. )
14 pz = geompy.MakeVertex(0. , 0. , 100.)
15 pxyz = geompy.MakeVertex(100., 100., 100.)
16 
17 # create a vector from two points
18 vxy = geompy.MakeVector(px, py)
19 
20 # create an arc from three points
21 arc = geompy.MakeArc(py, pz, px)
22 
23 # create a wire
24 wire = geompy.MakeWire([vxy, arc])
25 
26 # create an edge
27 edge = geompy.MakeEdge(p0, pxyz)
28 
29 # create a pipe
30 pipe = geompy.MakePipe(wire, edge)
31 
32 # add objects in the study
33 id_wire = geompy.addToStudy(wire,"Wire")
34 id_edge = geompy.addToStudy(edge,"Edge")
35 id_pipe = geompy.addToStudy(pipe,"Pipe")
36 
37 # display the wire, the edge (path) and the pipe
38 gg.createAndDisplayGO(id_wire)
39 gg.createAndDisplayGO(id_edge)
40 gg.createAndDisplayGO(id_pipe)
41 gg.setDisplayMode(id_pipe,1)

Download this script


Creation of a PipeWithDifferentSections

1 # Creation of a PipeWithDifferentSections
2 
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 gg = salome.ImportComponentGUI("GEOM")
9 
10 Wire_1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 100 0:R 0:C 100 90:T 0 200", [0, 0, 0, 0, 0, 1, 1, 0, -0])
11 edges = geompy.SubShapeAll(Wire_1, geompy.ShapeType["EDGE"])
12 vertices = geompy.SubShapeAll(Wire_1, geompy.ShapeType["VERTEX"])
13 
14 # create sections
15 circles=[]
16 circles.append(geompy.MakeCircle(vertices[0], edges[0], 20))
17 circles.append(geompy.MakeCircle(vertices[1], edges[0], 40))
18 circles.append(geompy.MakeCircle(vertices[2], edges[2], 30))
19 circles.append(geompy.MakeCircle(vertices[3], edges[2], 20))
20 
21 # create pipes
22 Pipe1 = geompy.MakePipeWithDifferentSections(circles, vertices, Wire_1, 0, 0)
23 Pipe2 = geompy.MakePipeWithDifferentSectionsBySteps(circles, vertices, Wire_1)
24 
25 # add objects in the study
26 geompy.addToStudy(circles[0], "circles1")
27 geompy.addToStudy(circles[1], "circles2")
28 geompy.addToStudy(circles[2], "circles3")
29 geompy.addToStudy(circles[3], "circles4")
30 id_wire = geompy.addToStudy(Wire_1, "Path")
31 id_pipe1 = geompy.addToStudy(Pipe1, "Pipe1")
32 id_pipe2 = geompy.addToStudy(Pipe2, "Pipe2")
33 
34 # display the wire(path) and the pipe
35 gg.createAndDisplayGO(id_wire)
36 gg.createAndDisplayGO(id_pipe1)
37 gg.createAndDisplayGO(id_pipe2)
38 gg.setDisplayMode(id_pipe1,1)
39 gg.setDisplayMode(id_pipe2,1)

Download this script


Creation of a PipeWithShellSections

1 # Creation of a PipeWithShellSections
2 
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 import math
9 gg = salome.ImportComponentGUI("GEOM")
10 
11 # create path
12 WirePath = geompy.MakeSketcher("Sketcher:F 0 0:TT 100 0:R 0:C 100 90:T 0 200", [0, 0, 0, 0, 0, 1, 1, 0, -0])
13 
14 # get sub-shapes
15 edges = geompy.SubShapeAll(WirePath, geompy.ShapeType["EDGE"])
16 vertices = geompy.SubShapeAll(WirePath, geompy.ShapeType["VERTEX"])
17 
18 
19 #=======================================================
20 # Create shell sections
21 #=======================================================
22 ps = [vertices[0],vertices[1],vertices[2],vertices[3]]
23 theLocations = [vertices[0],vertices[1],vertices[2],vertices[3]]
24 VC = geompy.MakeCompound(theLocations)
25 geompy.addToStudy(VC,"VC")
26 vs = [edges[0],edges[0],edges[2],edges[2]]
27 hs = [20,40,30,20]
28 shells = []
29 subbases = []
30 
31 # 1 section
32 c0 = geompy.PointCoordinates(ps[0])
33 c1 = geompy.PointCoordinates(ps[1])
34 nx = c1[0] - c0[0]
35 ny = c1[1] - c0[1]
36 nz = c1[2] - c0[2]
37 
38 faces = []
39 f1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 20 0:TT 20 20:TT 0 20:WF",
40  [c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1])
41 f2 = geompy.MakeSketcher("Sketcher:F 0 0:TT 0 20:TT -20 20:TT -20 0:WF",
42  [c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1])
43 f3 = geompy.MakeSketcher("Sketcher:F 0 0:TT -20 0:TT -20 -20:TT 0 -20:WF",
44  [c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1])
45 f4 = geompy.MakeSketcher("Sketcher:F 0 0:TT 0 -20:TT 20 -20:TT 20 0:WF",
46  [c0[0], c0[1], c0[2], nx, ny, nz, 0, 0, 1])
47 faces.append(f1)
48 faces.append(f2)
49 faces.append(f3)
50 faces.append(f4)
51 shell = geompy.MakeSewing(faces,1.e-6)
52 shells.append(shell)
53 faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"])
54 subbases.append(faces[0])
55 
56 # 2 section
57 faces = []
58 
59 w = geompy.MakeSketcher("Sketcher:F 20 20:TT 0 20:TT 0 0:TT 20 0",
60  [c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1])
61 contour = geompy.CloseContour(w, [], isCommonVertex=False)
62 [e1,e2,e3,e4] = geompy.SubShapeAll(contour, geompy.ShapeType["EDGE"])
63 w = geompy.MakeWire([e1,e2,e3,e4])
64 f1 = geompy.MakeFace(w,1)
65 
66 w = geompy.MakeSketcher("Sketcher:F -20 0:TT 0 0:TT 0 20:TT -20 20",
67  [c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1])
68 contour = geompy.CloseContour(w, [], isCommonVertex=False)
69 [e1,e2,e3,e4] = geompy.SubShapeAll(contour, geompy.ShapeType["EDGE"])
70 w = geompy.MakeWire([e1,e2,e3,e4])
71 f2 = geompy.MakeFace(w,1)
72 
73 w = geompy.MakeSketcher("Sketcher:F 20 0:TT 0 0:TT 0 -20:TT 20 -20",
74  [c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1])
75 contour = geompy.CloseContour(w, [], isCommonVertex=False)
76 [e1,e2,e3,e4] = geompy.SubShapeAll(contour, geompy.ShapeType["EDGE"])
77 w = geompy.MakeWire([e1,e2,e3,e4])
78 f3 = geompy.MakeFace(w,1)
79 
80 w = geompy.MakeSketcher("Sketcher:F -20 -20:TT 0 -20:TT 0 0:TT -20 0",
81  [c1[0], c1[1], c1[2], nx, ny, nz, 0, 0, 1])
82 contour = geompy.CloseContour(w, [], isCommonVertex=False)
83 [e1,e2,e3,e4] = geompy.SubShapeAll(contour, geompy.ShapeType["EDGE"])
84 w = geompy.MakeWire([e1,e2,e3,e4])
85 f4 = geompy.MakeFace(w,1)
86 
87 faces.append(f1)
88 faces.append(f2)
89 faces.append(f3)
90 faces.append(f4)
91 shell = geompy.MakeSewing(faces,1.e-6)
92 shells.append(shell)
93 faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"])
94 subbases.append(faces[0])
95 
96 # 3 section
97 faces = []
98 c2 = geompy.PointCoordinates(ps[2])
99 c3 = geompy.PointCoordinates(ps[3])
100 nx = c3[0] - c2[0]
101 ny = c3[1] - c2[1]
102 nz = c3[2] - c2[2]
103 
104 w = geompy.MakeSketcher("Sketcher:F 20 20:TT 0 20:TT 0 0:TT 20 0",
105  [c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1])
106 contour = geompy.CloseContour(w, [], isCommonVertex=False)
107 [e1,e2,e3,e4] = geompy.SubShapeAll(contour, geompy.ShapeType["EDGE"])
108 w = geompy.MakeWire([e1,e2,e3,e4])
109 f1 = geompy.MakeFace(w,1)
110 
111 w = geompy.MakeSketcher("Sketcher:F -20 0:TT 0 0:TT 0 20:TT -20 20",
112  [c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1])
113 contour = geompy.CloseContour(w, [], isCommonVertex=False)
114 [e1,e2,e3,e4] = geompy.SubShapeAll(contour, geompy.ShapeType["EDGE"])
115 w = geompy.MakeWire([e1,e2,e3,e4])
116 f2 = geompy.MakeFace(w,1)
117 
118 w = geompy.MakeSketcher("Sketcher:F 20 0:TT 0 0:TT 0 -20:TT 20 -20",
119  [c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1])
120 contour = geompy.CloseContour(w, [], isCommonVertex=False)
121 [e1,e2,e3,e4] = geompy.SubShapeAll(contour, geompy.ShapeType["EDGE"])
122 w = geompy.MakeWire([e1,e2,e3,e4])
123 f3 = geompy.MakeFace(w,1)
124 
125 w = geompy.MakeSketcher("Sketcher:F -20 -20:TT 0 -20:TT 0 0:TT -20 0",
126  [c2[0], c2[1], c2[2], nx, ny, nz, 0, 0, 1])
127 contour = geompy.CloseContour(w, [], isCommonVertex=False)
128 [e1,e2,e3,e4] = geompy.SubShapeAll(contour, geompy.ShapeType["EDGE"])
129 w = geompy.MakeWire([e1,e2,e3,e4])
130 f4 = geompy.MakeFace(w,1)
131 
132 faces.append(f1)
133 faces.append(f2)
134 faces.append(f3)
135 faces.append(f4)
136 shell = geompy.MakeSewing(faces,1.e-6)
137 shells.append(shell)
138 faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"])
139 subbases.append(faces[2])
140 
141 # 4 section
142 faces = []
143 
144 kk = 4
145 dx = c3[0] - nx/kk
146 dy = c3[1] - ny/kk
147 dz = c3[2] - nz/kk
148 rad = math.sqrt(nx*nx+ny*ny+nz*nz)
149 vc = geompy.MakeVertex(dx,dy,dz)
150 sph = geompy.MakeSpherePntR(vc,rad/kk)
151 shellsph = geompy.SubShapeAll(sph, geompy.ShapeType["SHELL"])
152 
153 fs = []
154 vec = geompy.MakeVectorDXDYDZ(0,0,1)
155 ff = geompy.MakePlane(ps[3],vec,40)
156 fs.append(ff)
157 vp = geompy.MakeVertex(c3[0],c3[1],c3[2]+20)
158 ff = geompy.MakePlane(vp,vec,40)
159 fs.append(ff)
160 vp = geompy.MakeVertex(c3[0],c3[1],c3[2]-20)
161 ff = geompy.MakePlane(vp,vec,40)
162 fs.append(ff)
163 vec = geompy.MakeVectorDXDYDZ(1,0,0)
164 ff = geompy.MakePlane(ps[3],vec,40)
165 fs.append(ff)
166 vp = geompy.MakeVertex(c3[0]+20,c3[1],c3[2])
167 ff = geompy.MakePlane(vp,vec,40)
168 fs.append(ff)
169 vp = geompy.MakeVertex(c3[0]-20,c3[1],c3[2])
170 ff = geompy.MakePlane(vp,vec,40)
171 fs.append(ff)
172 aPartition = geompy.MakePartition(shellsph,fs)
173 fs = geompy.SubShapeAllSortedCentres(aPartition, geompy.ShapeType["FACE"])
174 
175 for face in fs:
176  if ( 4 == geompy.NbShapes(face, geompy.ShapeType["VERTEX"]) ):
177  faces.append(face)
178  pass
179  pass
180 shell = geompy.MakeSewing(faces,1.e-6)
181 shells.append(shell)
182 faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType["FACE"])
183 subbases.append(faces[2])
184 
185 #===========================================================
186 # Create Pipe
187 #===========================================================
188 Pipe = geompy.MakePipeWithShellSections(shells, subbases, theLocations, WirePath,
189  theWithContact=0, theWithCorrection=0)
190 
191 # add objects in the study
192 resc = geompy.MakeCompound(shells)
193 id_sec = geompy.addToStudy(resc,"sections")
194 id_wire = geompy.addToStudy(WirePath,"WirePath")
195 id_pipe = geompy.addToStudy(Pipe, "Pipe")
196 
197 # display the wire(path), sections and the pipe
198 gg.createAndDisplayGO(id_wire)
199 gg.createAndDisplayGO(id_sec)
200 gg.createAndDisplayGO(id_pipe)
201 gg.setDisplayMode(id_pipe,1)

Download this script


Creation of a PipeShellsWithoutPath

1 # Creation of a PipeShellsWithoutPath
2 
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 import salome
9 gg = salome.ImportComponentGUI("GEOM")
10 
11 # Add a section based on quadrangles
12 # ----------------------------------
13 def section(s, p1, p2=None, p3=None, p4=None):
14  if p2==None:
15  q = p1
16  else:
17  q = geompy.MakeQuad4Vertices(p1, p2, p3, p4)
18  pass
19  s.append(q)
20  publish(q, "section")
21  return q
22 
23 
24 # find distance between two points
25 # -------------------------------
26 def Dist(p1,p2):
27  c1 = geompy.PointCoordinates(p1)
28  c2 = geompy.PointCoordinates(p2)
29  return math.sqrt( (c2[0]-c1[0])*(c2[0]-c1[0]) +
30  (c2[1]-c1[1])*(c2[1]-c1[1]) +
31  (c2[2]-c1[2])*(c2[2]-c1[2]) )
32 
33 
34 # return middle point
35 # -------------------------------
36 def MiddleVert(p1,p2):
37  c1 = geompy.PointCoordinates(p1)
38  c2 = geompy.PointCoordinates(p2)
39  return geompy.MakeVertex( (c2[0]+c1[0])/2, (c2[1]+c1[1])/2, (c2[2]+c1[2])/2 )
40 
41 
42 # Complex section
43 # result - 16 quads from lines
44 # pnt - point from path
45 # vec - direction from path
46 def MakeComplexSect(pnt,vec,rmax,rmin,nb):
47  dang = 1.0/nb/2
48  cmax = geompy.MakeCircle(pnt,vec,rmax)
49  cmin = geompy.MakeCircle(pnt,vec,rmin)
50  faces = []
51  for i in range(0,2*nb,2):
52  p1 = geompy.MakeVertexOnCurve(cmin,dang*i)
53  p2 = geompy.MakeVertexOnCurve(cmax,dang*(i+1))
54  p3 = geompy.MakeVertexOnCurve(cmin,dang*(i+2))
55  f = geompy.MakeQuad4Vertices(pnt,p1,p2,p3)
56  faces.append(f)
57  pass
58  shell = geompy.MakeSewing(faces,1.e-6)
59  return shell
60 
61 
62 #=======================================================
63 # Create simple path and recieve points
64 # for section creation
65 #=======================================================
66 WirePath = geompy.MakeSketcher("Sketcher:F 0 0:T 60 0:T 40 0:R 0:C 100 90:",
67  [0, 0, 0, 0, 0, 1, 1, 0, 0])
68 vs = geompy.SubShapeAll(WirePath, geompy.ShapeType["VERTEX"])
69 
70 #=======================================================
71 # Create shell sections
72 #=======================================================
73 shells = []
74 subbases = []
75 locs = []
76 
77 # 1 section
78 shell = MakeComplexSect(vs[0], geompy.MakeVectorDXDYDZ(1,0,0), 60, 40, 16)
79 shells.append(shell)
80 vs1 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"])
81 locs.append(vs1[17])
82 
83 # 2 section
84 shell = MakeComplexSect(vs[1], geompy.MakeVectorDXDYDZ(1,0,0), 80, 30, 16)
85 shells.append(shell)
86 vs2 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"])
87 locs.append(vs2[17])
88 
89 # 3 section
90 shell = MakeComplexSect(vs[2], geompy.MakeVectorDXDYDZ(1,0,0), 60, 40, 16)
91 shells.append(shell)
92 vs3 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"])
93 locs.append(vs3[17])
94 
95 # 4 section
96 shell = MakeComplexSect(vs[3], geompy.MakeVectorDXDYDZ(0,1,0), 40, 35, 16)
97 shells.append(shell)
98 vs4 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType["VERTEX"])
99 locs.append(vs4[17])
100 
101 
102 #===========================================================
103 # Create Pipe
104 #===========================================================
105 
106 Pipe = geompy.MakePipeShellsWithoutPath(shells,locs)
107 
108 # add objects in the study
109 resc = geompy.MakeCompound(shells)
110 id_sec = geompy.addToStudy(resc,"sections")
111 resl = geompy.MakeCompound(locs)
112 id_loc = geompy.addToStudy(resl,"locations")
113 id_pipe = geompy.addToStudy(Pipe, "Pipe")
114 
115 # display the sections, locations and pipe
116 gg.createAndDisplayGO(id_sec)
117 gg.createAndDisplayGO(id_loc)
118 gg.createAndDisplayGO(id_pipe)
119 gg.setDisplayMode(id_pipe,1)

Download this script


Creation of a PipeBiNormalAlongVector

1 # Creation of a PipeBiNormalAlongVector
2 import salome
3 salome.salome_init()
4 import GEOM
5 from salome.geom import geomBuilder
6 geompy = geomBuilder.New(salome.myStudy)
7 
8 def MakeHelix(radius, height, rotation, direction):
9  # - create a helix -
10  radius = 1.0 * radius
11  height = 1.0 * height
12  rotation = 1.0 * rotation
13  if direction > 0:
14  direction = +1
15  else:
16  direction = -1
17  pass
18  from math import sqrt
19  length_z = height
20  length_xy = radius*rotation
21  length = sqrt(length_z*length_z + length_xy*length_xy)
22  nb_steps = 1
23  epsilon = 1.0e-6
24  while 1:
25  z_step = height / nb_steps
26  angle_step = rotation / nb_steps
27  z = 0.0
28  angle = 0.0
29  helix_points = []
30  for n in range(nb_steps+1):
31  from math import cos, sin
32  x = radius * cos(angle)
33  y = radius * sin(angle)
34  p = geompy.MakeVertex(x, y, z)
35  helix_points.append( p )
36  z += z_step
37  angle += direction * angle_step
38  pass
39  helix = geompy.MakeInterpol(helix_points)
40  length_test = geompy.BasicProperties(helix)[0]
41  prec = abs(length-length_test)/length
42  # print nb_steps, length_test, prec
43  if prec < epsilon:
44  break
45  nb_steps *= 2
46  pass
47  return helix
48 
49 def MakeSpring(radius, height, rotation, direction, thread_radius, base_rotation=0.0):
50  # - create a pipe -
51  thread_radius = 1.0 * thread_radius
52  # create a helix
53  helix = MakeHelix(radius, height, rotation, direction)
54  # base in the (Ox, Oz) plane
55  p0 = geompy.MakeVertex(radius-3*thread_radius, 0.0, -thread_radius)
56  p1 = geompy.MakeVertex(radius+3*thread_radius, 0.0, -thread_radius)
57  p2 = geompy.MakeVertex(radius+3*thread_radius, 0.0, +thread_radius)
58  p3 = geompy.MakeVertex(radius-3*thread_radius, 0.0, +thread_radius)
59  e0 = geompy.MakeEdge(p0, p1)
60  e1 = geompy.MakeEdge(p1, p2)
61  e2 = geompy.MakeEdge(p2, p3)
62  e3 = geompy.MakeEdge(p3, p0)
63  w = geompy.MakeWire([e0, e1, e2, e3])
64  # create a base face
65  base = geompy.MakeFace(w, True)
66  # create a binormal vector
67  binormal = geompy.MakeVectorDXDYDZ(0.0, 0.0, 10.0)
68  # create a pipe
69  spring = geompy.MakePipeBiNormalAlongVector(base, helix, binormal)
70  # Publish in the study
71  geompy.addToStudy(base, "base")
72  geompy.addToStudy(helix, "helix")
73  geompy.addToStudy(binormal, "binormal")
74  geompy.addToStudy(spring, "spring")
75  return spring
76 
77 from math import pi
78 
79 spring = MakeSpring(50, 100, 2*pi, 1, 5, pi/2)

Download this script


Creation of a Middle Path

1 # Creation of a Middle Path
2 
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 
9 # Create a box
10 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
11 
12 # Get two opposite faces
13 [Face_1,Face_2] = geompy.SubShapes(Box_1, [31, 33])
14 
15 # Get edges
16 Box_1_edge_12 = geompy.GetSubShape(Box_1, [12])
17 Box_1_edge_22 = geompy.GetSubShape(Box_1, [22])
18 Box_1_edge_25 = geompy.GetSubShape(Box_1, [25])
19 Box_1_edge_29 = geompy.GetSubShape(Box_1, [29])
20 Box_1_edge_8 = geompy.GetSubShape(Box_1, [8])
21 Box_1_edge_18 = geompy.GetSubShape(Box_1, [18])
22 Box_1_edge_26 = geompy.GetSubShape(Box_1, [26])
23 Box_1_edge_30 = geompy.GetSubShape(Box_1, [30])
24 
25 # These three calls to RestorePath return the same result
26 Path_1 = geompy.RestorePath(Box_1, Face_1, Face_2)
27 Path_2 = geompy.RestorePathEdges(Box_1, [Face_1], [Face_2])
28 Path_3 = geompy.RestorePathEdges(Box_1,
29  [Box_1_edge_12, Box_1_edge_22, Box_1_edge_25, Box_1_edge_29],
30  [Box_1_edge_8, Box_1_edge_18, Box_1_edge_26, Box_1_edge_30])
31 
32 # Publish created objects
33 geompy.addToStudy( Box_1, 'Box_1' )
34 geompy.addToStudyInFather( Box_1, Face_1, 'Face_1' )
35 geompy.addToStudyInFather( Box_1, Face_2, 'Face_2' )
36 geompy.addToStudyInFather( Box_1, Box_1_edge_25, 'Box_1:edge_25' )
37 geompy.addToStudyInFather( Box_1, Box_1_edge_22, 'Box_1:edge_22' )
38 geompy.addToStudyInFather( Box_1, Box_1_edge_12, 'Box_1:edge_12' )
39 geompy.addToStudyInFather( Box_1, Box_1_edge_29, 'Box_1:edge_29' )
40 geompy.addToStudyInFather( Box_1, Box_1_edge_18, 'Box_1:edge_18' )
41 geompy.addToStudyInFather( Box_1, Box_1_edge_26, 'Box_1:edge_26' )
42 geompy.addToStudyInFather( Box_1, Box_1_edge_8, 'Box_1:edge_8' )
43 geompy.addToStudyInFather( Box_1, Box_1_edge_30, 'Box_1:edge_30' )
44 geompy.addToStudy( Path_1, 'Path_1' )
45 geompy.addToStudy( Path_2, 'Path_2' )
46 geompy.addToStudy( Path_3, 'Path_3' )

Download this script


Creation of Tangent Plane On Face

1 # Creation of Tangent Plane On Face
2 
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 
9 # Create Vertexes for curve
10 Vertex_1 = geompy.MakeVertex(0, 0, 0)
11 Vertex_2 = geompy.MakeVertex(0, 90, 30)
12 Vertex_3 = geompy.MakeVertex(100, 90, 0)
13 Vertex_4 = geompy.MakeVertex(-100, 90, 0)
14 # Create curve
15 Curve_1 = geompy.MakeInterpol([Vertex_4, Vertex_2, Vertex_3, Vertex_1])
16 # Create Face by Extrusion of the Curve
17 Extrusion_1 = geompy.MakePrismDXDYDZ(Curve_1, 0, 30, -60)
18 # Make Tangent on this Extrusion (Face)
19 Tangent_1 = geompy.MakeTangentPlaneOnFace(Extrusion_1, 0.7, 0.5, 150)
20 # Publish in the study
21 geompy.addToStudy( Vertex_1, "Vertex_1" )
22 geompy.addToStudy( Vertex_2, "Vertex_2" )
23 geompy.addToStudy( Vertex_3, "Vertex_3" )
24 geompy.addToStudy( Vertex_4, "Vertex_4" )
25 geompy.addToStudy( Curve_1, "Curve_1" )
26 geompy.addToStudy( Extrusion_1, "Extrusion_1" )
27 geompy.addToStudy( Tangent_1, "Tangent_1" )

Download this script


Applying a Thickness to Face, Shell or Solid

1 # Apply thickness for shell
2 
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 gg = salome.ImportComponentGUI("GEOM")
9 
10 # create box
11 box = geompy.MakeBoxDXDYDZ(100, 100, 100)
12 
13 # get the list of faces
14 faces = geompy.SubShapeAllSortedCentres(box, geompy.ShapeType["FACE"])
15 
16 # get the list of face IDs
17 faceIDs = geompy.SubShapeAllSortedCentresIDs(box, geompy.ShapeType["FACE"])
18 
19 # make a shell from 3 faces
20 shell = geompy.MakeShell([faces[0], faces[1], faces[2]])
21 
22 # apply thickness
23 solid = geompy.MakeThickSolid(shell, 30.)
24 
25 # create box
26 hsolid = geompy.MakeBoxDXDYDZ(100, 100, 100)
27 
28 # make hollowed solid
29 geompy.Thicken(hsolid, 30., [faceIDs[0], faceIDs[1]])
30 
31 # add objects in the study
32 id_shell = geompy.addToStudy(shell, "Shell")
33 id_solid = geompy.addToStudy(solid, "Solid")
34 id_hsolid = geompy.addToStudy(hsolid, "Hollowed Solid")
35 
36 # display the shell and the result thicknen solid and hollowed solid
37 gg.createAndDisplayGO(id_shell)
38 gg.createAndDisplayGO(id_solid)
39 gg.createAndDisplayGO(id_hsolid)

Download this script