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


Creation of an Edge

1 # Creation of an Edge
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 #
11 # create edge by two points
12 #
13 
14 # create vertices
15 p0 = geompy.MakeVertex(0. , 0. , 0. )
16 pxyz = geompy.MakeVertex(100., 100., 100.)
17 
18 # create an edge
19 edge = geompy.MakeEdge(p0, pxyz)
20 
21 # add object in the study
22 id_edge = geompy.addToStudy(edge,"Edge_1")
23 
24 # display an edge
25 gg.createAndDisplayGO(id_edge)
26 
27 #
28 # create edge from wire
29 #
30 
31 # create a circle
32 c = geompy.MakeCircle(None, None, 100)
33 
34 # create a wire
35 w = geompy.MakeWire([c], 1e-07)
36 
37 # create an edge from wire
38 edge = geompy.MakeEdgeWire(w)
39 
40 # add object in the study
41 id_edge = geompy.addToStudy(edge,"Edge_2")
42 
43 # display an edge
44 gg.createAndDisplayGO(id_edge)
45 
46 #
47 # create edge from existing curve and a length
48 #
49 
50 # create a circle
51 c = geompy.MakeCircle(None, None, 100)
52 
53 # create an edge of length 25.0 from the circle
54 edge = geompy.MakeEdgeOnCurveByLength(c, 25.0)
55 
56 # add object in the study
57 id_edge = geompy.addToStudy(edge,"Edge_3")
58 
59 # display an edge
60 gg.createAndDisplayGO(id_edge)

Download this script


Creation of a Wire

1 # Creation of a Wire
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 px = geompy.MakeVertex(100., 0. , 0. )
12 py = geompy.MakeVertex(0. , 100., 0. )
13 pz = geompy.MakeVertex(0. , 0. , 100.)
14 
15 # create a vector from two points
16 vxy = geompy.MakeVector(px, py)
17 
18 # create an arc from three points
19 arc = geompy.MakeArc(py, pz, px)
20 
21 # create a wire
22 wire = geompy.MakeWire([vxy, arc])
23 
24 # add an object in the study
25 id_wire = geompy.addToStudy(wire,"Wire")
26 
27 # display the wire
28 gg.createAndDisplayGO(id_wire)

Download this script


Creation of a Face

1 # Creation of a 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 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 sketchers
27 sketcher1 = geompy.MakeSketcher("Sketcher:F -100 -100:TT 250 -100:R 0:C 100 150:R 0:L 300:WW",
28  [100,0,0, 1,1,1, -1,1,0])
29 sketcher2 = geompy.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW")
30 sketcher3 = geompy.MakeSketcher("Sketcher:F 20 20:TT 50 20:TT 50 50:TT 20 50:WW")
31 isPlanarFace = 1
32 
33 sphere = geompy.MakeSphereR(100)
34 box = geompy.MakeBoxDXDYDZ(200, 200, 200)
35 cut = geompy.MakeCutList(sphere, [box], True)
36 
37 # create a face from the wire
38 face1 = geompy.MakeFace(wire, isPlanarFace)
39 
40 # create faces from two wires
41 face2 = geompy.MakeFaceWires([wire, sketcher1],isPlanarFace)
42 face3 = geompy.MakeFaces([sketcher2, sketcher3],isPlanarFace)
43 face4 = geompy.MakeFaceFromSurface(face1, sketcher1)
44 
45 # create face from edges with constraints
46 face5 = geompy.MakeFaceWithConstraints([geompy.GetSubShape(cut, [5]), geompy.GetSubShape(cut, [3]),
47  geompy.GetSubShape(cut, [11]), geompy.GetSubShape(cut, [3]),
48  geompy.GetSubShape(cut, [13]), geompy.GetSubShape(cut, [3])])
49 
50 # add objects in the study
51 id_face1 = geompy.addToStudy(face1,"Face1")
52 id_face2 = geompy.addToStudy(face2,"Face2")
53 id_face3 = geompy.addToStudy(face3,"Face3")
54 id_face4 = geompy.addToStudy(face4,"Face4")
55 id_face5 = geompy.addToStudy(face5,"Face5")
56 
57 # display the faces
58 gg.createAndDisplayGO(id_face1)
59 gg.setDisplayMode(id_face1,1)
60 gg.setTransparency(id_face1,0.2)
61 gg.createAndDisplayGO(id_face2)
62 gg.setDisplayMode(id_face2,1)
63 gg.setTransparency(id_face2,0.2)
64 gg.createAndDisplayGO(id_face3)
65 gg.setDisplayMode(id_face3,1)
66 gg.setTransparency(id_face3,0.2)
67 gg.createAndDisplayGO(id_face4)
68 gg.setDisplayMode(id_face4,1)
69 gg.setTransparency(id_face4,0.2)
70 gg.createAndDisplayGO(id_face5)
71 gg.setDisplayMode(id_face5,1)
72 gg.setTransparency(id_face5,0.2)

Download this script


Creation of a Shell

1 # Creation of a 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 vertices
11 p0 = geompy.MakeVertex( 0., 0., 0.)
12 pxyz = geompy.MakeVertex( 5., 5., 40.)
13 
14 # create sketchers
15 sketcher1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW")
16 sketcher2 = geompy.MakeSketcher("Sketcher:F 20 20:TT 50 20:TT 50 50:TT 20 50:WW")
17 isPlanarFace = 1
18 
19 # create a face from two wires
20 face = geompy.MakeFaces([sketcher1, sketcher2],isPlanarFace)
21 
22 # create a prism
23 prism = geompy.MakePrism(face, p0, pxyz)
24 
25 # explode the prism into faces
26 prism_faces = geompy.SubShapeAllSortedCentres(prism, geompy.ShapeType["FACE"])
27 
28 # create a shell from a set of faces
29 shell = geompy.MakeShell([prism_faces[0], prism_faces[2], prism_faces[3],
30  prism_faces[7], prism_faces[9]])
31 
32 # add objects in the study
33 id_shell = geompy.addToStudy(shell,"Shell")
34 
35 # display the shell
36 gg.createAndDisplayGO(id_shell)
37 gg.setDisplayMode(id_shell,1)

Download this script


Creation of a Solid

1 # Creation of a Solid
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 pz = geompy.MakeVertex( 0., 0., 40.)
13 
14 # create sketchers
15 sketcher = geompy.MakeSketcher("Sketcher:F -50 -50:TT 100 -50:R 0:C 50 70:R 0:L 100:WW")
16 
17 # create faces from two wires
18 face = geompy.MakeFace(sketcher,1)
19 
20 # create a prism
21 prism = geompy.MakePrism(face, p0, pz)
22 
23 # explode the prism into faces
24 prism_faces = geompy.SubShapeAllSortedCentres(prism, geompy.ShapeType["FACE"])
25 
26 # create a shell from a set of faces
27 shell = geompy.MakeShell([prism_faces[0], prism_faces[1],
28  prism_faces[3], prism_faces[4],
29  prism_faces[5], prism_faces[2]])
30 
31 # create a solid, bounded by the given shells
32 solid = geompy.MakeSolid([shell])
33 
34 # add objects in the study
35 id_solid = geompy.addToStudy(solid,"Solid")
36 
37 # display the solid
38 gg.createAndDisplayGO(id_solid)
39 gg.setDisplayMode(id_solid,1)

Download this script


Creation of a Solid from the set of connected faces

1 # Creation of a Solid(s) from connected faces
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 box
11 box = geompy.MakeBoxDXDYDZ(200, 200, 200)
12 
13 # make a copy of a box translated by X coordinate
14 box_translation = geompy.MakeTranslation(box, 200, 0, 0)
15 
16 # extract shells from boxes
17 box_shell = geompy.SubShapeAllSorted(box, geompy.ShapeType["SHELL"])[0]
18 box_translation_shell = geompy.SubShapeAllSorted(box_translation, geompy.ShapeType["SHELL"])[0]
19 
20 # extract faces from boxes
21 box_faces = geompy.SubShapeAllSorted(box, geompy.ShapeType["FACE"])
22 box_translation_faces = geompy.SubShapeAllSorted(box_translation, geompy.ShapeType["FACE"])
23 
24 # create solids from shells
25 msf_shells_noint = geompy.MakeSolidFromConnectedFaces([box_shell, box_translation_shell],0)
26 msf_shells_int = geompy.MakeSolidFromConnectedFaces([box_shell, box_translation_shell], 1)
27 
28 # create solids from faces
29 msf_faces_noint = geompy.MakeSolidFromConnectedFaces(box_faces+box_translation_faces, 0)
30 msf_faces_int = geompy.MakeSolidFromConnectedFaces(box_faces+box_translation_faces, 1)
31 
32 # add objects in the study
33 id_solid_shells_noint = geompy.addToStudy(msf_shells_noint,"Solid_from_shells_no_intersect")
34 id_solid_shells_int = geompy.addToStudy(msf_shells_int,"Solid_from_shells_intersect")
35 id_solid_faces_noint = geompy.addToStudy(msf_faces_noint,"Solid_from_faces_no_intersect")
36 id_solid_faces_int = geompy.addToStudy(msf_faces_int,"Solid_from_faces_intersect")
37 
38 # display the results
39 gg.createAndDisplayGO(id_solid_shells_noint)
40 gg.setDisplayMode(id_solid_shells_noint,1)
41 gg.createAndDisplayGO(id_solid_shells_int)
42 gg.setDisplayMode(id_solid_shells_int,1)
43 gg.createAndDisplayGO(id_solid_faces_noint)
44 gg.setDisplayMode(id_solid_faces_noint,1)
45 gg.createAndDisplayGO(id_solid_faces_int)
46 gg.setDisplayMode(id_solid_faces_int,1)

Download this script


Creation of a Compound

1 # Creation of a Compound
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( -30., -30., 50.)
12 p2 = geompy.MakeVertex( -60., -60., 30.)
13 p3 = geompy.MakeVertex( -30., -30., 10.)
14 
15 # create an arc from three points
16 arc = geompy.MakeArc(p1, p2, p3)
17 ShapeListCompound = []
18 i = 0
19 while i <= 3 :
20  S = geompy.MakeTranslation(arc, i * 50., 0., 0.)
21  ShapeListCompound.append(S)
22  i = i + 1
23 
24 # create a compund of the given shapes
25 compound = geompy.MakeCompound(ShapeListCompound)
26 
27 # add object in the study
28 id_compound = geompy.addToStudy(compound,"Compound")
29 
30 # display the compound
31 gg.createAndDisplayGO(id_compound)

Download this script