Advanced Geometrical Objects

Creation of an Edge

import geompy

import salome

gg = salome.ImportComponentGUI("GEOM")

 

# create vertices

p0   = geompy.MakeVertex(0.  , 0.  , 0.  )

pxyz = geompy.MakeVertex(100., 100., 100.)

 

# create edge

edge = geompy.MakeEdge(p0, pxyz)

 

# add object in study

id_edge = geompy.addToStudy(edge,"Edge")

 

# display edge

gg.createAndDisplayGO(id_edge)

 

Creation of a Wire

import geompy

import salome

gg = salome.ImportComponentGUI("GEOM")

 

# create vertices

px   = geompy.MakeVertex(100., 0.  , 0.  )

py   = geompy.MakeVertex(0.  , 100., 0.  )

pz   = geompy.MakeVertex(0.  , 0.  , 100.)

 

# create vector on two points

vxy = geompy.MakeVector(px, py)

 

# create arc with three points

arc = geompy.MakeArc(py, pz, px)

 

# create wire

wire = geompy.MakeWire([vxy, arc])

 

# add object in study

id_wire = geompy.addToStudy(wire,"Wire")

 

# display wire

gg.createAndDisplayGO(id_wire)

 

 

Creation of a Face

import geompy

import salome

gg = salome.ImportComponentGUI("GEOM")

 

# create vertices

p0   = geompy.MakeVertex(0.  , 0.  , 0.  )

px   = geompy.MakeVertex(100., 0.  , 0.  )

py   = geompy.MakeVertex(0.  , 100., 0.  )

pz   = geompy.MakeVertex(0.  , 0.  , 100.)

pxyz = geompy.MakeVertex(100., 100., 100.)

 

# create vector on two points

vxy = geompy.MakeVector(px, py)

 

# create arc with three points

arc = geompy.MakeArc(py, pz, px)

 

# create wire

wire = geompy.MakeWire([vxy, arc])

 

# create sketchers

sketcher1 = geompy.MakeSketcher("Sketcher:F -100 -100:TT 250 -100:R 0:C 100 150:R 0:L 300:WW",

                                [100,0,0, 1,1,1, -1,1,0])

sketcher2 = geompy.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW")

sketcher3 = geompy.MakeSketcher("Sketcher:F 20 20:TT 50 20:TT 50 50:TT 20 50:WW")

isPlanarFace = 1

 

# create face from wire

face1 = geompy.MakeFace(wire, isPlanarFace)

 

# create faces from two wires

face2 = geompy.MakeFaceWires([wire, sketcher1],isPlanarFace)

face3 = geompy.MakeFaces([sketcher2, sketcher3],isPlanarFace)

 

# add objects in study

id_face1 = geompy.addToStudy(face1,"Face1")

id_face2 = geompy.addToStudy(face2,"Face2")

id_face3 = geompy.addToStudy(face3,"Face3")

 

# display faces

gg.createAndDisplayGO(id_face1)

gg.setDisplayMode(id_face1,1)

gg.setTransparency(id_face1,0.2)

gg.createAndDisplayGO(id_face2)

gg.setDisplayMode(id_face2,1)

gg.setTransparency(id_face2,0.2)

gg.createAndDisplayGO(id_face3)

gg.setDisplayMode(id_face3,1)

gg.setTransparency(id_face3,0.2)

 

Creation of a Shell

import geompy

import salome

gg = salome.ImportComponentGUI("GEOM")

 

#create vertices

p0   = geompy.MakeVertex( 0.,  0.,  0.)

pxyz = geompy.MakeVertex( 5.,  5., 40.)

 

# create sketchers

sketcher1 = geompy.MakeSketcher("Sketcher:F 0 0:TT 70 0:TT 70 70:TT 0 70:WW")

sketcher2 = geompy.MakeSketcher("Sketcher:F 20 20:TT 50 20:TT 50 50:TT 20 50:WW")

isPlanarFace = 1

 

# create face from two wires

face = geompy.MakeFaces([sketcher1, sketcher2],isPlanarFace)

 

# create prism

prism = geompy.MakePrism(face, p0, pxyz)

 

# explode prism on faces

prism_faces = geompy.SubShapeAllSorted(prism, geompy.ShapeType["FACE"])

 

# create shell from the set of faces

shell = geompy.MakeShell([prism_faces[0], prism_faces[2], prism_faces[3],

                          prism_faces[7], prism_faces[9]])

 

# add objects in study

id_shell = geompy.addToStudy(shell,"Shell")

 

# display shell

gg.createAndDisplayGO(id_shell)

gg.setDisplayMode(id_shell,1)

 

Creation of a Solid

import geompy

import salome

gg = salome.ImportComponentGUI("GEOM")

 

#create vertices

p0 = geompy.MakeVertex( 0.,  0.,  0.)

pz = geompy.MakeVertex( 0.,  0., 40.)

 

# create sketchers

sketcher = geompy.MakeSketcher("Sketcher:F -50 -50:TT 100 -50:R 0:C 50 70:R 0:L 100:WW")

 

# create faces from two wires

face = geompy.MakeFace(sketcher,1)

 

# create prism

prism = geompy.MakePrism(face, p0, pz)

 

# explode prism on faces

prism_faces = geompy.SubShapeAllSorted(prism, geompy.ShapeType["FACE"])

 

# create shell from the set of faces

shell = geompy.MakeShell([prism_faces[0], prism_faces[1],

                          prism_faces[3], prism_faces[4],

                          prism_faces[5], prism_faces[2]])

 

# create solid, bounded by the given shells

solid = geompy.MakeSolid([shell])

 

# add objects in study

id_solid = geompy.addToStudy(solid,"Solid")

 

# display solid

gg.createAndDisplayGO(id_solid)

gg.setDisplayMode(id_solid,1)

 

Creation of a Compound

import geompy

import salome

gg = salome.ImportComponentGUI("GEOM")

 

#create vertices

p0 = geompy.MakeVertex( 0.,  0.,  0.)

pz = geompy.MakeVertex( 0.,  0., 40.)

 

# create sketchers

sketcher = geompy.MakeSketcher("Sketcher:F -50 -50:TT 100 -50:R 0:C 50 70:R 0:L 100:WW")

 

# create faces from two wires

face = geompy.MakeFace(sketcher,1)

 

# create prism

prism = geompy.MakePrism(face, p0, pz)

 

# explode prism on faces

prism_faces = geompy.SubShapeAllSorted(prism, geompy.ShapeType["FACE"])

 

# create shell from the set of faces

shell = geompy.MakeShell([prism_faces[0], prism_faces[1],

                          prism_faces[3], prism_faces[4],

                          prism_faces[5], prism_faces[2]])

 

# create solid, bounded by the given shells

solid = geompy.MakeSolid([shell])

 

# add objects in study

id_solid = geompy.addToStudy(solid,"Solid")

 

# display solid

gg.createAndDisplayGO(id_solid)

gg.setDisplayMode(id_solid,1)