# Building by Blocks

### Quadrangle Face

import geompy

import salome

gg = salome.ImportComponentGUI("GEOM")

# create vertices

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

p2 = geompy.MakeVertex(150., 30., 0.)

p3 = geompy.MakeVertex( 0., 120., 50.)

p4 = geompy.MakeVertex( 0., 40., 70.)

# create edges

edge1 = geompy.MakeEdge(p1, p2)

edge2 = geompy.MakeEdge(p2, p3)

edge3 = geompy.MakeEdge(p3, p4)

edge4 = geompy.MakeEdge(p4, p1)

# create quadrangle face from four edges

qface1 = geompy.MakeQuad(edge1, edge2, edge3, edge4)

# create quadrangle face on two edges

qface2 = geompy.MakeQuad2Edges(edge1, edge3)

# create quadrangle with specified corners

qface3 = geompy.MakeQuad4Vertices(p1, p2, p3, p4)

# add objects in study

id_p1 = geompy.addToStudy(p1,"Point1")

id_p2 = geompy.addToStudy(p2,"Point2")

id_p3 = geompy.addToStudy(p3,"Point3")

id_p4 = geompy.addToStudy(p4,"Point4")

id_edge1 = geompy.addToStudy(edge1,"Edge1")

id_edge2 = geompy.addToStudy(edge2,"Edge2")

id_edge3 = geompy.addToStudy(edge3,"Edge3")

id_edge4 = geompy.addToStudy(edge4,"Edge4")

id_qface1 = geompy.addToStudy(qface1,"Qface1")

id_qface2 = geompy.addToStudy(qface2,"Qface2")

id_qface3 = geompy.addToStudy(qface3,"Qface3")

# display vertices, edges and quadrangle faces

gg.createAndDisplayGO(id_p1)

gg.createAndDisplayGO(id_p2)

gg.createAndDisplayGO(id_p3)

gg.createAndDisplayGO(id_p4)

gg.createAndDisplayGO(id_edge1)

gg.createAndDisplayGO(id_edge2)

gg.createAndDisplayGO(id_edge3)

gg.createAndDisplayGO(id_edge4)

gg.createAndDisplayGO(id_qface1)

gg.setDisplayMode(id_qface1,1)

gg.createAndDisplayGO(id_qface2)

gg.setDisplayMode(id_qface2,1)

gg.createAndDisplayGO(id_qface3)

gg.setDisplayMode(id_qface3,1)

###

### Hexagonal Solid

import geompy

import salome

gg = salome.ImportComponentGUI("GEOM")

# create vertices

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

p2 = geompy.MakeVertex(150., 30., 0.)

p3 = geompy.MakeVertex( 0., 120., 50.)

p4 = geompy.MakeVertex( 0., 40., 70.)

p5 = geompy.MakeVertex(100., 20., 45.)

p6 = geompy.MakeVertex( 0., 70., 40.)

p7 = geompy.MakeVertex( 70., 70., 70.)

p8 = geompy.MakeVertex( 70.,-15., 70.)

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

p10 = geompy.MakeVertex( 0., 70., 0.)

p11 = geompy.MakeVertex( 70., 70., 0.)

p12 = geompy.MakeVertex( 70., -15., 0.)

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

# create faces

qface1 = geompy.MakeQuad4Vertices(p1, p2, p3, p4)

qface2 = geompy.MakeQuad4Vertices(p1, p2, p5, p4)

qface3 = geompy.MakeQuad4Vertices(p13, p12, p11, p10)

qface4 = geompy.MakeQuad4Vertices(p9, p8, p7, p6)

qface5 = geompy.MakeQuad4Vertices(p13, p9, p6, p10)

qface6 = geompy.MakeQuad4Vertices(p13, p9, p8, p12)

qface7 = geompy.MakeQuad4Vertices(p12, p8, p7, p11)

qface8 = geompy.MakeQuad4Vertices(p11, p7, p6, p10)

# create hexahedral solid between two given faces

solid1 = geompy.MakeHexa2Faces(qface1, qface2)

# create hexahedral solids, bounded by the six given faces

solid2 = geompy.MakeHexa(qface3, qface4, qface5, qface6, qface7, qface8)

# add objects in study

id_solid1 = geompy.addToStudy(solid1,"Solid1")

id_solid2 = geompy.addToStudy(solid2,"Solid2")

# display solids

gg.createAndDisplayGO(id_solid1)

gg.setDisplayMode(id_solid1,1)

gg.createAndDisplayGO(id_solid2)

gg.setDisplayMode(id_solid2,1)