Complex Objects

Creation of a Prism

import geompy

import salome

gg = salome.ImportComponentGUI("GEOM")

 

# create vertex and vector

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

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

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

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

p5 = geompy.MakeVertex(   0.,   0.,  60.)

p6 = geompy.MakeVertex(-100.,   0.,   0.)

p7 = geompy.MakeVertex(-100.,-100.,   0.)

p8 = geompy.MakeVertex(   0.,-100.,   0.)

 

# create vector with the given components

vector = geompy.MakeVectorDXDYDZ(50., 50., 50.)

 

#create vectors with two points

vector1_arc1 = geompy.MakeVector(p1, p2)

vector2_arc1 = geompy.MakeVector(p1, p4)

vector1_arc2 = geompy.MakeVector(p1, p6)

vector2_arc2 = geompy.MakeVector(p1, p8)

 

# create arcs with three points

arc1 = geompy.MakeArc(p2, p3, p4)

arc2 = geompy.MakeArc(p6, p7, p8)

 

# create wires

wire1 = geompy.MakeWire([vector1_arc1, arc1, vector2_arc1])

wire2 = geompy.MakeWire([vector1_arc2, arc2, vector2_arc2])

 

# create faces

isPlanarWanted = 1

face1 = geompy.MakeFace(wire1, isPlanarWanted)

face2 = geompy.MakeFace(wire2, isPlanarWanted)

 

# create prisms

prism1 = geompy.MakePrism(face2, p1, p5)

prism2 = geompy.MakePrismVecH(face1, vector, 50)

 

# add objects in study

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

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

id_prism1 = geompy.addToStudy(prism1,"Prism1")

id_prism2 = geompy.addToStudy(prism2,"Prism2")

 

# display cylinders

gg.createAndDisplayGO(id_face1)

gg.setDisplayMode(id_face1,1)

gg.createAndDisplayGO(id_face2)

gg.setDisplayMode(id_face2,1)

gg.createAndDisplayGO(id_prism1)

gg.setDisplayMode(id_prism1,1)

gg.createAndDisplayGO(id_prism2)

gg.setDisplayMode(id_prism2,1)

Creation of a Revolution

import geompy

import salome

gg = salome.ImportComponentGUI("GEOM")

 

# create vertex and vector

p1 = geompy.MakeVertex(  10.,  10.,  10.)

p2 = geompy.MakeVertex(  15.,  15.,  50.)

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

 

#create vectors with two points

vector1 = geompy.MakeVector(p1, p2)

vector2 = geompy.MakeVector(p1, p3)

 

# create vector with the given components

vector3 = geompy.MakeVectorDXDYDZ(-20., -20., 100.)

 

# create wire

wire = geompy.MakeWire([vector1, vector2])

 

# create revolution

revolution = geompy.MakeRevolution(wire, vector3, 2.3)

 

# add objects in study

id_vector3    = geompy.addToStudy(vector3,"Axis")

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

id_revolution = geompy.addToStudy(revolution,"Revolution")

 

# display vector, wire and revolution

gg.createAndDisplayGO(id_vector3)

gg.createAndDisplayGO(id_wire)

gg.createAndDisplayGO(id_revolution)

gg.setDisplayMode(id_revolution,1)

Creation of a Filling

import geompy

import salome

gg = salome.ImportComponentGUI("GEOM")

mindeg = 2

maxdeg = 5

tol3d   = 0.0001

tol2d   = 0.0001

nbiter = 5

 

# create vertex and vector

p1 = geompy.MakeVertex(  -30.,  -30.,  50.)

p2 = geompy.MakeVertex(  -60.,  -60.,  30.)

p3 = geompy.MakeVertex(  -30.,  -30.,  10.)

 

# create arc with three points

arc = geompy.MakeArc(p1, p2, p3)

ShapeListCompound = []

i = 0

while i <= 3 :

    S = geompy.MakeTranslation(arc, i * 50., 0., 0.)

    ShapeListCompound.append(S)

    i = i + 1

compound = geompy.MakeCompound(ShapeListCompound)

 

# create filling

filling = geompy.MakeFilling(compound, mindeg, maxdeg, tol3d, tol2d, nbiter)

 

# add objects in study

id_compound = geompy.addToStudy(compound,"Compound")

id_filling = geompy.addToStudy(filling,"Filling")

 

# display compound and filling

gg.createAndDisplayGO(id_compound)

gg.createAndDisplayGO(id_filling)

gg.setDisplayMode(id_filling,1)

 

Creation of a Pipe

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 edge

edge = geompy.MakeEdge(p0, pxyz)

 

# create pipe

pipe = geompy.MakePipe(wire, edge)

 

# add objects in study

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

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

id_pipe = geompy.addToStudy(pipe,"Pipe")

 

# display wire, edge (path) and pipe

gg.createAndDisplayGO(id_wire)

gg.createAndDisplayGO(id_edge)

gg.createAndDisplayGO(id_pipe)

gg.setDisplayMode(id_pipe,1)