6 from salome.geom
import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 gg = salome.ImportComponentGUI(
"GEOM")
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.)
21 vector = geompy.MakeVectorDXDYDZ(50., 50., 50.)
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)
30 arc1 = geompy.MakeArc(p2, p3, p4)
31 arc2 = geompy.MakeArc(p6, p7, p8)
34 wire1 = geompy.MakeWire([vector1_arc1, arc1, vector2_arc1])
35 wire2 = geompy.MakeWire([vector1_arc2, arc2, vector2_arc2])
39 face1 = geompy.MakeFace(wire1, isPlanarWanted)
40 face2 = geompy.MakeFace(wire2, isPlanarWanted)
43 prism1 = geompy.MakePrism(face2, p1, p5)
44 prism2 = geompy.MakePrismVecH(face1, vector, 50)
45 prism3 = geompy.MakePrismVecH2Ways(face1, vector, 50)
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")
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)
6 from salome.geom
import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 gg = salome.ImportComponentGUI(
"GEOM")
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"])
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))
22 Pipe1 = geompy.MakePipeWithDifferentSections(circles, vertices, Wire_1, 0, 0)
23 Pipe2 = geompy.MakePipeWithDifferentSectionsBySteps(circles, vertices, Wire_1)
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")
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)
6 from salome.geom
import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
9 gg = salome.ImportComponentGUI(
"GEOM")
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])
15 edges = geompy.SubShapeAll(WirePath, geompy.ShapeType[
"EDGE"])
16 vertices = geompy.SubShapeAll(WirePath, geompy.ShapeType[
"VERTEX"])
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]]
32 c0 = geompy.PointCoordinates(ps[0])
33 c1 = geompy.PointCoordinates(ps[1])
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])
51 shell = geompy.MakeSewing(faces,1.e-6)
53 faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType[
"FACE"])
54 subbases.append(faces[0])
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)
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)
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)
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)
91 shell = geompy.MakeSewing(faces,1.e-6)
93 faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType[
"FACE"])
94 subbases.append(faces[0])
98 c2 = geompy.PointCoordinates(ps[2])
99 c3 = geompy.PointCoordinates(ps[3])
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)
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)
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)
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)
136 shell = geompy.MakeSewing(faces,1.e-6)
138 faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType[
"FACE"])
139 subbases.append(faces[2])
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"])
154 vec = geompy.MakeVectorDXDYDZ(0,0,1)
155 ff = geompy.MakePlane(ps[3],vec,40)
157 vp = geompy.MakeVertex(c3[0],c3[1],c3[2]+20)
158 ff = geompy.MakePlane(vp,vec,40)
160 vp = geompy.MakeVertex(c3[0],c3[1],c3[2]-20)
161 ff = geompy.MakePlane(vp,vec,40)
163 vec = geompy.MakeVectorDXDYDZ(1,0,0)
164 ff = geompy.MakePlane(ps[3],vec,40)
166 vp = geompy.MakeVertex(c3[0]+20,c3[1],c3[2])
167 ff = geompy.MakePlane(vp,vec,40)
169 vp = geompy.MakeVertex(c3[0]-20,c3[1],c3[2])
170 ff = geompy.MakePlane(vp,vec,40)
172 aPartition = geompy.MakePartition(shellsph,fs)
173 fs = geompy.SubShapeAllSortedCentres(aPartition, geompy.ShapeType[
"FACE"])
176 if ( 4 == geompy.NbShapes(face, geompy.ShapeType[
"VERTEX"]) ):
180 shell = geompy.MakeSewing(faces,1.e-6)
182 faces = geompy.SubShapeAllSortedCentres(shell, geompy.ShapeType[
"FACE"])
183 subbases.append(faces[2])
188 Pipe = geompy.MakePipeWithShellSections(shells, subbases, theLocations, WirePath,
189 theWithContact=0, theWithCorrection=0)
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")
198 gg.createAndDisplayGO(id_wire)
199 gg.createAndDisplayGO(id_sec)
200 gg.createAndDisplayGO(id_pipe)
201 gg.setDisplayMode(id_pipe,1)
6 from salome.geom
import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
9 gg = salome.ImportComponentGUI(
"GEOM")
13 def section(s, p1, p2=None, p3=None, p4=None):
17 q = geompy.MakeQuad4Vertices(p1, p2, p3, p4)
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]) )
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 )
46 def MakeComplexSect(pnt,vec,rmax,rmin,nb):
48 cmax = geompy.MakeCircle(pnt,vec,rmax)
49 cmin = geompy.MakeCircle(pnt,vec,rmin)
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)
58 shell = geompy.MakeSewing(faces,1.e-6)
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"])
78 shell = MakeComplexSect(vs[0], geompy.MakeVectorDXDYDZ(1,0,0), 60, 40, 16)
80 vs1 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType[
"VERTEX"])
84 shell = MakeComplexSect(vs[1], geompy.MakeVectorDXDYDZ(1,0,0), 80, 30, 16)
86 vs2 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType[
"VERTEX"])
90 shell = MakeComplexSect(vs[2], geompy.MakeVectorDXDYDZ(1,0,0), 60, 40, 16)
92 vs3 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType[
"VERTEX"])
96 shell = MakeComplexSect(vs[3], geompy.MakeVectorDXDYDZ(0,1,0), 40, 35, 16)
98 vs4 = geompy.SubShapeAllSortedCentres(shell,geompy.ShapeType[
"VERTEX"])
106 Pipe = geompy.MakePipeShellsWithoutPath(shells,locs)
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")
116 gg.createAndDisplayGO(id_sec)
117 gg.createAndDisplayGO(id_loc)
118 gg.createAndDisplayGO(id_pipe)
119 gg.setDisplayMode(id_pipe,1)
5 from salome.geom
import geomBuilder
6 geompy = geomBuilder.New(salome.myStudy)
8 def MakeHelix(radius, height, rotation, direction):
12 rotation = 1.0 * rotation
20 length_xy = radius*rotation
21 length = sqrt(length_z*length_z + length_xy*length_xy)
25 z_step = height / nb_steps
26 angle_step = rotation / nb_steps
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 )
37 angle += direction * angle_step
39 helix = geompy.MakeInterpol(helix_points)
40 length_test = geompy.BasicProperties(helix)[0]
41 prec = abs(length-length_test)/length
49 def MakeSpring(radius, height, rotation, direction, thread_radius, base_rotation=0.0):
51 thread_radius = 1.0 * thread_radius
53 helix = MakeHelix(radius, height, rotation, direction)
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])
65 base = geompy.MakeFace(w,
True)
67 binormal = geompy.MakeVectorDXDYDZ(0.0, 0.0, 10.0)
69 spring = geompy.MakePipeBiNormalAlongVector(base, helix, binormal)
71 geompy.addToStudy(base,
"base")
72 geompy.addToStudy(helix,
"helix")
73 geompy.addToStudy(binormal,
"binormal")
74 geompy.addToStudy(spring,
"spring")
79 spring = MakeSpring(50, 100, 2*pi, 1, 5, pi/2)
6 from salome.geom
import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
10 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
13 [Face_1,Face_2] = geompy.SubShapes(Box_1, [31, 33])
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])
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])
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' )