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(200,0,0)
13 p3 = geompy.MakeVertex(100,150,0)
14 edge = geompy.MakeEdge(p1,p2)
15 arc = geompy.MakeArc(p1,p3,p2)
16 wire = geompy.MakeWire([edge,arc])
17 face = geompy.MakeFace(wire, 1)
18 theShape = geompy.MakePrismVecH(face, edge, 130)
21 print "Before ProcessShape:"
22 isValid = geompy.CheckShape(theShape)
24 print "The shape is not valid"
26 print "The shape seems to be valid"
29 Operators = [
"FixShape"]
30 Parameters = [
"FixShape.Tolerance3d"]
32 PS = geompy.ProcessShape(theShape, Operators, Parameters, Values)
35 print "After ProcessShape:"
36 isValid = geompy.CheckShape(PS)
38 print "The shape is not valid"
39 raise RuntimeError,
"It seems, that the ProcessShape() has failed"
41 print "The shape seems to be valid"
44 Id_Shape = geompy.addToStudy(theShape,
"Invalid Shape")
45 Id_PS = geompy.addToStudy(PS,
"Processed Shape")
46 gg.createAndDisplayGO(Id_Shape)
47 gg.setDisplayMode(Id_Shape,1)
48 gg.createAndDisplayGO(Id_PS)
49 gg.setDisplayMode(Id_PS,1)
6 from salome.geom
import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 gg = salome.ImportComponentGUI(
"GEOM")
11 box = geompy.MakeBoxDXDYDZ(200, 200, 200)
15 sup_faces = geompy.SubShapeAllSortedCentres(box, geompy.ShapeType[
"FACE"])
18 f1_id = geompy.GetSubShapeID(box, sup_faces[3])
21 result = geompy.SuppressFaces(box, [f1_id])
24 id_box = geompy.addToStudy(box,
"Box")
25 id_result = geompy.addToStudy(result,
"Result")
28 gg.createAndDisplayGO(id_box)
29 gg.setDisplayMode(id_box,1)
30 gg.createAndDisplayGO(id_result)
31 gg.setDisplayMode(id_result,1)
6 from salome.geom
import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 gg = salome.ImportComponentGUI(
"GEOM")
11 p0 = geompy.MakeVertex( 0., 0., 0.)
12 px = geompy.MakeVertex(100., 0., 0.)
13 py = geompy.MakeVertex( 0., 100., 0.)
14 py1 = geompy.MakeVertex( 0., 140., 0.)
15 pz = geompy.MakeVertex( 0., 0., 100.)
16 vxy = geompy.MakeVector(px, py)
19 arc = geompy.MakeArc(py1, pz, px)
22 wire = geompy.MakeWire([vxy, arc])
25 wire_close = geompy.CloseContour(wire, [1], 0)
28 id_wire = geompy.addToStudy(wire,
"Wire")
29 id_wire_close = geompy.addToStudy(wire_close,
"Wire close")
32 gg.createAndDisplayGO(id_wire)
33 gg.createAndDisplayGO(id_wire_close)
6 from salome.geom
import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 gg = salome.ImportComponentGUI(
"GEOM")
11 p1 = geompy.MakeVertex(55, 65, 50)
12 p2 = geompy.MakeVertex(55, 0, 50)
13 v = geompy.MakeVector(p1, p2)
18 cylinder = geompy.MakeCylinder(p1, v, radius1, height)
21 box = geompy.MakeBoxDXDYDZ(100, 100, 100)
24 cut = geompy.MakeCut(box, cylinder)
27 result = geompy.SuppressInternalWires(cut, [])
30 id_cut = geompy.addToStudy(cut,
"Cut")
31 id_result = geompy.addToStudy(result,
"Result")
34 gg.createAndDisplayGO(id_cut)
35 gg.setDisplayMode(id_cut,1)
36 gg.createAndDisplayGO(id_result)
37 gg.setDisplayMode(id_result,1)
6 from salome.geom
import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 gg = salome.ImportComponentGUI(
"GEOM")
11 p1 = geompy.MakeVertex(35, 35, 0)
12 p2 = geompy.MakeVertex(35, 35, 50)
13 v = geompy.MakeVector(p1, p2)
18 cylinder = geompy.MakeCylinder(p1, v, radius1, height)
21 cone = geompy.MakeCone(p1, v, 70, 0, 80)
24 cut = geompy.MakeCut(cone, cylinder)
27 faces = geompy.SubShapeAllSortedCentres(cut, geompy.ShapeType[
"FACE"])
28 f_2 = geompy.GetSubShapeID(cut, faces[2])
31 cut_without_f_2 = geompy.SuppressFaces(cut, [f_2])
34 edges = geompy.SubShapeAllSortedCentres(faces[2], geompy.ShapeType[
"EDGE"])
35 edge = geompy.GetInPlace(cut_without_f_2, edges[0],
True)
36 e_2 = geompy.GetSubShapeID(cut_without_f_2, edge)
39 result = geompy.SuppressHoles(cut_without_f_2, [e_2])
42 id_cut = geompy.addToStudy(cut,
"Cut")
43 id_cut_without_f_2 = geompy.addToStudy(cut_without_f_2,
"Cut without f_2")
44 id_result = geompy.addToStudy(result,
"Result")
47 gg.createAndDisplayGO(id_cut)
48 gg.setDisplayMode(id_cut,1)
49 gg.createAndDisplayGO(id_cut_without_f_2)
50 gg.setDisplayMode(id_cut_without_f_2,1)
51 gg.createAndDisplayGO(id_result)
52 gg.setDisplayMode(id_result,1)
5 from salome.geom
import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 gg = salome.ImportComponentGUI(
"GEOM")
11 px = geompy.MakeVertex(100., 0., 0.)
12 py = geompy.MakeVertex(0., 100., 0.)
13 pz = geompy.MakeVertex(0., 0., 100.)
16 vector = geompy.MakeVector(px, py)
17 arc = geompy.MakeArc(py, pz, px)
20 angle = 45. * math.pi / 180
22 wire = geompy.MakeWire([vector, arc])
23 face = geompy.MakeFace(wire, WantPlanarFace)
24 face_rot = geompy.MakeRotation(face, vector, angle)
28 sewing = geompy.MakeSewing([face, face_rot], precision)
31 id_face = geompy.addToStudy(face,
"Face")
32 id_face_rot = geompy.addToStudy(face_rot,
"Face rotation")
33 id_sewing = geompy.addToStudy(sewing,
"Sewing")
36 gg.createAndDisplayGO(id_face)
37 gg.setDisplayMode(id_face,1)
38 gg.createAndDisplayGO(id_face_rot)
39 gg.setDisplayMode(id_face_rot,1)
40 gg.createAndDisplayGO(id_sewing)
41 gg.setDisplayMode(id_sewing,1)
45 quad = geompy.MakeFaceHW( 10, 20, 1 )
46 quadCompound = geompy.MakeMultiTranslation1D( quad, geompy.MakeVectorDXDYDZ(1,0,0), 10, 3)
47 shell = geompy.Sew( quadCompound, 1e-6 )
49 id_shell = geompy.addToStudy( shell,
"3 quads shell")
50 gg.createAndDisplayGO(id_shell)
6 from salome.geom
import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 gg = salome.ImportComponentGUI(
"GEOM")
11 box1 = geompy.MakeBox(0,0,0,100,50,100)
12 box2 = geompy.MakeBox(100,0,0,250,50,100)
15 compound = geompy.MakeCompound([box1, box2])
19 glue = geompy.MakeGlueFaces(compound, tolerance)
22 id_box1 = geompy.addToStudy(box1,
"Box1")
23 id_box2 = geompy.addToStudy(box2,
"Box2")
24 id_compound = geompy.addToStudy(compound,
"Compound")
25 id_glue = geompy.addToStudy(glue,
"Glue faces")
28 gg.createAndDisplayGO(id_box1)
29 gg.setDisplayMode(id_box1,1)
30 gg.createAndDisplayGO(id_box2)
31 gg.setDisplayMode(id_box2,1)
32 gg.createAndDisplayGO(id_compound)
33 gg.setDisplayMode(id_compound,1)
34 gg.createAndDisplayGO(id_glue)
35 gg.setDisplayMode(id_glue,1)
6 from salome.geom
import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 gg = salome.ImportComponentGUI(
"GEOM")
11 box1 = geompy.MakeBox(0,0,0,100,50,100)
12 box2 = geompy.MakeBox(100,0,0,250,50,100)
15 compound = geompy.MakeCompound([box1, box2])
19 glue1 = geompy.MakeGlueEdges(compound, tolerance)
22 list_edges = geompy.GetGlueEdges(compound, tolerance)
23 glue2 = geompy.MakeGlueEdgesByList(compound, tolerance, [list_edges[0], list_edges[2]])
26 geompy.addToStudy(box1,
"Box1")
27 geompy.addToStudy(box2,
"Box2")
28 geompy.addToStudy(compound,
"Compound")
29 geompy.addToStudy(glue1,
"Glue all edges")
30 geompy.addToStudy(glue2,
"Glue two edges")
32 if salome.sg.hasDesktop():
33 salome.sg.updateObjBrowser(
True)
6 from salome.geom
import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 gg = salome.ImportComponentGUI(
"GEOM")
11 shape1 = geompy.ImportBREP(
"my_shape_1.brep")
12 shape2 = geompy.ImportBREP(
"my_shape_2.brep")
14 geompy.addToStudy(shape1,
"Shape 1")
15 geompy.addToStudy(shape2,
"Shape 2")
19 part = geompy.MakePartition([shape1, shape2])
23 shape1_lt = geompy.LimitTolerance(shape1, tolerance)
24 shape2_lt = geompy.LimitTolerance(shape2, tolerance)
27 good_shape1 = geompy.ProcessShape(shape1_lt, [
"FixShape"], [
"FixShape.Tolerance3d"], [
"1e-7"])
28 good_shape2 = geompy.ProcessShape(shape2_lt, [
"FixShape"], [
"FixShape.Tolerance3d"], [
"1e-7"])
30 geompy.addToStudy(good_shape1,
"Shape 1 corrected")
31 geompy.addToStudy(good_shape2,
"Shape 2 corrected")
34 part = geompy.MakePartition([good_shape1, good_shape2])
37 geompy.addToStudy(part,
"Partition")
6 from salome.geom
import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
12 p1 = geompy.MakeVertex(0,0,50)
13 p2 = geompy.MakeVertex(60,0,50)
16 edge = geompy.MakeEdge(p1, p2)
19 divide = geompy.DivideEdge(edge, -1, 0.5, 0)
22 id_edge = geompy.addToStudy(edge,
"Edge")
23 edge_points = geompy.SubShapeAllSortedCentres(edge, geompy.ShapeType[
"VERTEX"])
24 for point
in edge_points:
25 geompy.addToStudyInFather(edge, point,
"Edge's point")
27 id_divide = geompy.addToStudy(divide,
"Divided edge")
28 edge_points = geompy.SubShapeAllSortedCentres(divide, geompy.ShapeType[
"VERTEX"])
29 for point
in edge_points:
30 geompy.addToStudyInFather(divide, point,
"Edge's point after divide")
35 box = geompy.MakeBox(0,0,0, 10,10,10, theName=
"box")
36 p1 = geompy.MakeVertex( 3, -2, 1, theName=
"point 1 to project" )
37 p2 = geompy.MakeVertex( 7, -2, 1, theName=
"point 2 to project" )
38 edge = geompy.GetEdgeNearPoint( box, p1, theName=
"edge to split")
40 div = geompy.DivideEdgeByPoint( box, edge, [p1, p2], theName=
"box (edge divided)")
43 salome.sg.updateObjBrowser(
True)
6 from salome.geom
import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
10 p1 = geompy.MakeVertex(0, 0, 0)
11 p2 = geompy.MakeVertex(70, 0, 0)
12 p3 = geompy.MakeVertex(70, 50, 0)
13 p4 = geompy.MakeVertex(70, 80, 0)
14 p5 = geompy.MakeVertex(50, 80, 0)
15 p6 = geompy.MakeVertex(20, 80, 0)
16 p7 = geompy.MakeVertex(0, 80, 0)
17 p8 = geompy.MakeVertex(0, 30, 0)
19 points = [p1, p2, p3, p4, p5, p6, p7, p8]
22 wire_1 = geompy.MakePolyline(points,
True)
25 wire_2 = geompy.FuseCollinearEdgesWithinWire(wire_1, [p3])
26 wire_3 = geompy.FuseCollinearEdgesWithinWire(wire_1, [p5, p6])
29 wire_4 = geompy.FuseCollinearEdgesWithinWire(wire_1, [])
31 wires = [wire_1, wire_2, wire_3, wire_4]
36 geompy.addToStudy(point,
"p%d"%ii)
42 geompy.addToStudy(wire,
"wire_%d"%ii)
43 wire_points = geompy.SubShapeAllSortedCentres(wire, geompy.ShapeType[
"VERTEX"])
45 for point
in wire_points:
46 geompy.addToStudyInFather(wire, point,
"point_%d"%jj)
52 salome.sg.updateObjBrowser(
True)
6 from salome.geom
import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
10 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
11 Translation_1 = geompy.MakeTranslation(Box_1, 200, 0, 0)
12 Translation_2 = geompy.MakeTranslation(Box_1, 200, 200, 0)
14 geompy.addToStudy(Box_1,
'Box_1')
15 geompy.addToStudy(Translation_1,
'Translation_1')
16 geompy.addToStudy(Translation_2,
'Translation_2')
19 Partition_1 = geompy.MakePartition([Box_1, Translation_1, Translation_2])
20 geompy.addToStudy(Partition_1,
'Partition_1')
23 Joined_1 = geompy.RemoveInternalFaces(Partition_1)
24 geompy.addToStudy(Joined_1,
'Joined_1')
26 salome.sg.updateObjBrowser(
True)