Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Transformation Operations


Translation

1 # Translation
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(10, 40, 0)
12 p2 = geompy.MakeVertex( 0, 0, 50)
13 p3 = geompy.MakeVertex(50, 80, 0)
14 v = geompy.MakeVector(p1, p2)
15 vt = geompy.MakeVector(p1, p3)
16 
17 # create a cylinder
18 height = 35
19 radius1 = 20
20 cylinder = geompy.MakeCylinder(p1, v, radius1, height)
21 
22 # translate the given object along the vector, specified by its end points
23 # (all three functions produce the same result)
24 translation1 = geompy.MakeTranslationTwoPoints(cylinder, p1, p3)
25 translation2 = geompy.MakeTranslation(cylinder, 40, 40, 0)
26 translation3 = geompy.MakeTranslationVector(cylinder, vt)
27 translation4 = geompy.MakeTranslationVectorDistance(cylinder, vt, 200)
28 
29 # add objects in the study
30 id_cylinder = geompy.addToStudy(cylinder, "Cylinder")
31 id_translation1 = geompy.addToStudy(translation1, "Translation1")
32 id_translation2 = geompy.addToStudy(translation2, "Translation2")
33 id_translation3 = geompy.addToStudy(translation3, "Translation3")
34 id_translation4 = geompy.addToStudy(translation4, "Translation4")
35 
36 # display the results
37 gg.createAndDisplayGO(id_cylinder)
38 gg.setDisplayMode(id_cylinder,1)
39 gg.createAndDisplayGO(id_translation1)
40 gg.setDisplayMode(id_translation1,1)
41 gg.createAndDisplayGO(id_translation2)
42 gg.setDisplayMode(id_translation2,1)
43 gg.createAndDisplayGO(id_translation3)
44 gg.setDisplayMode(id_translation3,1)
45 gg.createAndDisplayGO(id_translation4)
46 gg.setDisplayMode(id_translation4,1)

Download this script


Rotation

1 # Rotation
2 
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 import math
9 gg = salome.ImportComponentGUI("GEOM")
10 
11 # create a vertex and a vector
12 p1 = geompy.MakeVertex(10, 40, 0)
13 p2 = geompy.MakeVertex( 0, 0, 50)
14 p3 = geompy.MakeVertex(10, 50,-20)
15 p4 = geompy.MakeVertex(10, 50, 60)
16 v = geompy.MakeVector(p1, p2)
17 vr = geompy.MakeVector(p3, p4)
18 
19 # create a cylinder
20 height = 35
21 radius1 = 20
22 cylinder = geompy.MakeCylinder(p1, v, radius1, height)
23 
24 # rotate the given object around the given axis by the given angle
25 rotation1 = geompy.MakeRotation(cylinder, vr, math.pi)
26 rotation2 = geompy.MakeRotationThreePoints(cylinder, p4, p1, p2)
27 
28 # add objects in the study
29 id_vr = geompy.addToStudy(vr, "Rotation 1 axis")
30 id_p4 = geompy.addToStudy(p4, "Rotation 2 center")
31 id_p1 = geompy.addToStudy(p1, "Rotation 2 point 1")
32 id_p2 = geompy.addToStudy(p2, "Rotation 2 point 2")
33 id_cylinder = geompy.addToStudy(cylinder, "Cylinder")
34 id_rotation1 = geompy.addToStudy(rotation1, "Rotation 1")
35 id_rotation2 = geompy.addToStudy(rotation2, "Rotation 2")
36 
37 # display the results
38 gg.createAndDisplayGO(id_vr)
39 gg.createAndDisplayGO(id_p4)
40 gg.createAndDisplayGO(id_p1)
41 gg.createAndDisplayGO(id_p2)
42 gg.createAndDisplayGO(id_cylinder)
43 gg.setDisplayMode(id_cylinder,1)
44 gg.createAndDisplayGO(id_rotation1)
45 gg.createAndDisplayGO(id_rotation2)
46 gg.setDisplayMode(id_rotation1,1)
47 gg.setDisplayMode(id_rotation2,1)

Download this script


Modify Location

1 # Modify Location
2 
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8 import math
9 gg = salome.ImportComponentGUI("GEOM")
10 
11 # create a vertex and a vector
12 p1 = geompy.MakeVertex(10, 40, 0)
13 p2 = geompy.MakeVertex( 0, 0, 50)
14 v = geompy.MakeVector(p1, p2)
15 
16 # create a cylinder
17 height = 35
18 radius1 = 20
19 cylinder = geompy.MakeCylinder(p1, v, radius1, height)
20 circle = geompy.MakeCircle(p2, v, radius1)
21 
22 # create local coordinate systems
23 cs1 = geompy.MakeMarker( 0, 0, 0, 1,0,0, 0,1,0)
24 cs2 = geompy.MakeMarker(30,40,40, 1,0,0, 0,1,0)
25 
26 # modify the location of the given object
27 position = geompy.MakePosition(cylinder, cs1, cs2)
28 position2 = geompy.PositionAlongPath(position, circle, 0.75, 1, 1)
29 
30 # add objects in the study
31 id_cs1 = geompy.addToStudy(cs1, "Coordinate system 1")
32 id_cs2 = geompy.addToStudy(cs2, "Coordinate system 2")
33 id_cylinder = geompy.addToStudy(cylinder, "Cylinder")
34 id_circle = geompy.addToStudy(circle, "Circle")
35 id_position = geompy.addToStudy(position, "Position")
36 id_position2 = geompy.addToStudy(position2, "PositionAlongPath")
37 
38 # display the results
39 gg.createAndDisplayGO(id_cylinder)
40 gg.setDisplayMode(id_cylinder,1)
41 gg.createAndDisplayGO(id_position)
42 gg.setDisplayMode(id_position,1)
43 gg.createAndDisplayGO(id_circle)
44 gg.setDisplayMode(id_circle,1)
45 gg.createAndDisplayGO(id_position2)
46 gg.setDisplayMode(id_position2,1)

Download this script


Mirror Image

1 # Mirror Image
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 # create an object, symmetrical to another object through the given plane
14 p1 = geompy.MakeVertex( 0, 25, 0)
15 p2 = geompy.MakeVertex( 5, 25, 0)
16 p3 = geompy.MakeVertex( 0,-30, 40)
17 plane = geompy.MakePlaneThreePnt(p1, p2, p3, 1000.)
18 mirror1 = geompy.MakeMirrorByPlane(box, plane)
19 
20 # create an object, symmetrical to another object through the given axis
21 p4 = geompy.MakeVertex( 210, 210, -20)
22 p5 = geompy.MakeVertex( 210, 210, 220)
23 axis = geompy.MakeVector(p4, p5)
24 mirror2 = geompy.MakeMirrorByAxis(box, axis)
25 
26 # create an object, symmetrical to another object through the given point
27 mirror3 = geompy.MakeMirrorByPoint(box, p4)
28 
29 # add objects in the study
30 id_box = geompy.addToStudy(box, "Box")
31 id_plane = geompy.addToStudy(plane, "Plane")
32 id_mirror1 = geompy.addToStudy(mirror1, "Mirror plane")
33 id_axis = geompy.addToStudy(axis, "Axis")
34 id_mirror2 = geompy.addToStudy(mirror2, "Mirror axis")
35 id_p4 = geompy.addToStudy(p4, "Point")
36 id_mirror3 = geompy.addToStudy(mirror3, "Mirror point")
37 
38 # display the results
39 gg.createAndDisplayGO(id_box)
40 gg.setDisplayMode(id_box,1)
41 gg.createAndDisplayGO(id_plane)
42 gg.createAndDisplayGO(id_mirror1)
43 gg.setDisplayMode(id_mirror1,1)
44 gg.createAndDisplayGO(id_axis)
45 gg.createAndDisplayGO(id_mirror2)
46 gg.setDisplayMode(id_mirror2,1)
47 gg.createAndDisplayGO(id_p4)
48 gg.createAndDisplayGO(id_mirror3)
49 gg.setDisplayMode(id_mirror3,1)

Download this script


Scale Transform

1 # Scale Transform
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 and a sphere
11 box = geompy.MakeBoxDXDYDZ(200, 200, 200)
12 
13 # scale the given object by the factor
14 p0 = geompy.MakeVertex(100, 100, 100)
15 factor = 0.5
16 scale = geompy.MakeScaleTransform(box, p0, factor)
17 
18 # add objects in the study
19 id_box = geompy.addToStudy(box, "Box")
20 id_scale = geompy.addToStudy(scale, "Scale")
21 
22 # display the results
23 gg.createAndDisplayGO(id_box)
24 gg.setDisplayMode(id_box,1)
25 gg.setTransparency(id_box,0.5)
26 gg.createAndDisplayGO(id_scale)
27 gg.setDisplayMode(id_scale,1)

Download this script


Offset Surface

1 # Offset Surface
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 and a sphere
11 box = geompy.MakeBox(20, 20, 20, 200, 200, 200)
12 
13 # create a new object as offset of the given object
14 offset = geompy.MakeOffset(box, 70.)
15 
16 # add objects in the study
17 id_box = geompy.addToStudy(box, "Box")
18 id_offset = geompy.addToStudy(offset, "Offset")
19 
20 # display the results
21 gg.createAndDisplayGO(id_box)
22 gg.setDisplayMode(id_box,1)
23 gg.createAndDisplayGO(id_offset)

Download this script


Projection

1 # Projection
2 
3 import salome
4 salome.salome_init()
5 from salome.geom import geomBuilder
6 geompy = geomBuilder.New(salome.myStudy)
7 
8 # create a cylindric face and a curve(edge)
9 cylinder = geompy.MakeCylinderRH(100, 300)
10 [face_cyl] = geompy.SubShapes(cylinder, [3])
11 
12 p1 = geompy.MakeVertex(200, 0, 100)
13 p2 = geompy.MakeVertex(200, 80, 100)
14 p3 = geompy.MakeVertex(200, 80, 180)
15 p4 = geompy.MakeVertex(130, 80, 180)
16 p5 = geompy.MakeVertex(90, 80, 240)
17 
18 curve = geompy.MakeInterpol([p1, p2, p3, p4, p5], False, False)
19 
20 # create a new object as projection of the
21 # given curve on the given cylindric face
22 projection = geompy.MakeProjection(curve, face_cyl)
23 
24 # add objects in the study
25 geompy.addToStudy(cylinder, "cylinder")
26 geompy.addToStudyInFather(cylinder, face_cyl, "face_cyl")
27 geompy.addToStudy(curve, "curve")
28 geompy.addToStudy(projection, "projection")
29 
30 #projection of point on wire
31 e1 = geompy.MakeLineTwoPnt(p1, p2)
32 e2 = geompy.MakeLineTwoPnt(p2, p3)
33 
34 w1 = geompy.MakeWire([e1, e2], 1.e-7)
35 v1 = geompy.MakeVertex(300, 40, 100)
36 
37 prj = geompy.MakeProjection(v1, w1)
38 geompy.addToStudy(w1, "w1")
39 geompy.addToStudy(v1, "v1")
40 geompy.addToStudy(prj, "projOnWire")
41 
42 #projection of a wire on cylinder
43 pp1 = geompy.MakeVertex(100, 200, 0)
44 pp2 = geompy.MakeVertex(100, 200, 80)
45 pp3 = geompy.MakeVertex(100, 220, 90)
46 pp4 = geompy.MakeVertex(100, 130, 80)
47 pp5 = geompy.MakeVertex(100, 90, 80)
48 cc1 = geompy.MakeInterpol([pp1, pp2, pp3, pp4, pp5], True, False)
49 ww1 = geompy.MakeWire([cc1], 1.e-7)
50 vx = geompy.MakeVectorDXDYDZ(100, 0, 0)
51 pln1 = geompy.MakePlane(pp1, vx, 200)
52 face1 = geompy.MakeFaceFromSurface(pln1, ww1)
53 prj_cyl = geompy.MakeProjectionOnCylinder(face1, 100)
54 
55 geompy.addToStudy(face1, "pln_face")
56 geompy.addToStudy(prj_cyl, "projOnCylinder")

Download this script


Multi Translation

1 # Multi Translation
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 and vectors
11 p0 = geompy.MakeVertex( 0., 0., 0.)
12 px = geompy.MakeVertex(20., 0., 0.)
13 py = geompy.MakeVertex( 0., 20., 0.)
14 pz = geompy.MakeVertex( 0., 0., 20.)
15 pxy = geompy.MakeVertex( 50., 0., 0.)
16 pxyz = geompy.MakeVertex( 50., 50., 50.)
17 vz = geompy.MakeVector(p0, pz)
18 vxy = geompy.MakeVector(px, py)
19 vtr1d = geompy.MakeVector(p0, pxyz)
20 vtr2d = geompy.MakeVector(p0, pxy)
21 
22 # create an arc
23 arc = geompy.MakeArc(py, pz, px)
24 
25 # create a wire
26 wire = geompy.MakeWire([vxy, arc])
27 
28 # create a planar face
29 face = geompy.MakeFace(wire, 1)
30 
31 # create a prism
32 prism = geompy.MakePrismVecH(face, vz, 20.0)
33 
34 # translate the given object along the given vector a given number of times
35 tr1d = geompy.MakeMultiTranslation1D(prism, vtr1d, 20, 4)
36 
37 # consequently apply two specified translations to the object a given number of times
38 tr2d = geompy.MakeMultiTranslation2D(prism, vtr1d, 20, 4, vtr2d, 80, 3)
39 
40 # add objects in the study
41 id_prism = geompy.addToStudy(prism,"Prism")
42 id_tr1d = geompy.addToStudy(tr1d,"Translation 1D")
43 id_tr2d = geompy.addToStudy(tr2d,"Translation 2D")
44 
45 # display the prism and the results of fillet operation
46 gg.createAndDisplayGO(id_prism)
47 gg.setDisplayMode(id_prism,1)
48 gg.createAndDisplayGO(id_tr1d)
49 gg.setDisplayMode(id_tr1d,1)
50 gg.createAndDisplayGO(id_tr2d)
51 gg.setDisplayMode(id_tr2d,1)

Download this script


Multi Rotation

1 # Multi Rotation
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 import math
10 
11 # create vertices and vectors
12 p0 = geompy.MakeVertex( 0., 0., 0.)
13 px = geompy.MakeVertex(20., 0., 0.)
14 py = geompy.MakeVertex( 0., 20., 0.)
15 pz = geompy.MakeVertex( 0., 0., 20.)
16 pxyz = geompy.MakeVertex( 50., 50., 10.)
17 vz = geompy.MakeVector(p0, pz)
18 vxy = geompy.MakeVector(px, py)
19 vrot = geompy.MakeVector(p0, pxyz)
20 
21 # create an arc
22 arc = geompy.MakeArc(py, pz, px)
23 
24 # create a wire
25 wire = geompy.MakeWire([vxy, arc])
26 
27 # create a planar face
28 face = geompy.MakeFace(wire, 1)
29 
30 # create a prism
31 prism = geompy.MakePrismVecH(face, vz, 20.0)
32 
33 # 1. Rotate the prism around the axis vrot 4 times
34 
35 # rotation angle = 2 * PI / 4
36 rot1da = geompy.MultiRotate1DNbTimes(prism, vrot, 4)
37 
38 # by the given angle of 30 degrees
39 rot1db = geompy.MultiRotate1DByStep(prism, vrot, math.pi/6., 4)
40 
41 # 2. Rotate the prism around the axis vrot 4 times
42 # and translate the result of each rotation 5 times on distance 50
43 
44 # rotation angle = 2 * PI / 4
45 rot2da = geompy.MultiRotate2DNbTimes(prism, vrot, 4, 50, 5)
46 
47 # by the given angle of 60 degrees
48 rot2db = geompy.MultiRotate2DByStep(prism, vrot, math.pi/3., 4, 50, 5)
49 
50 # add objects in the study
51 id_prism = geompy.addToStudy(prism,"Prism")
52 id_rot1da = geompy.addToStudy(rot1da,"Rotation 1D Nb.Times")
53 id_rot1db = geompy.addToStudy(rot1db,"Rotation 1D By Step")
54 id_rot2da = geompy.addToStudy(rot2da,"Rotation 2D Nb.Times")
55 id_rot2db = geompy.addToStudy(rot2db,"Rotation 2D By Step")
56 
57 # display the prism and the results of fillet operation
58 gg.createAndDisplayGO(id_prism)
59 gg.setDisplayMode(id_prism,1)
60 gg.createAndDisplayGO(id_rot1da)
61 gg.setDisplayMode(id_rot1da,1)
62 gg.createAndDisplayGO(id_rot1db)
63 gg.setDisplayMode(id_rot1db,1)
64 gg.createAndDisplayGO(id_rot2da)
65 gg.setDisplayMode(id_rot2da,1)
66 gg.createAndDisplayGO(id_rot2db)
67 gg.setDisplayMode(id_rot2db,1)

Download this script


Fillet 2D

1 # Fillet 2D
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 face in OXY plane
11 face = geompy.MakeFaceHW(100, 100, 1)
12 fillet2d = geompy.MakeFillet2D(face, 30, [7, 9])
13 
14 # add objects in the study
15 id_face = geompy.addToStudy(face,"Face_1")
16 id_fillet2d = geompy.addToStudy(fillet2d,"Fillet 2D_1")
17 
18 # display disks
19 gg.createAndDisplayGO(id_face)
20 gg.createAndDisplayGO(id_fillet2d)

Download this script


Fillet 1D

1 # Fillet 1D
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 box
11 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
12 # take box edges to create custom complex wire
13 [Edge_1,Edge_2,Edge_3,Edge_4,Edge_5,Edge_6,Edge_7,Edge_8,Edge_9,Edge_10,Edge_11,Edge_12] = geompy.SubShapeAllSortedCentres(Box_1, geompy.ShapeType["EDGE"])
14 # create wire
15 Wire_1 = geompy.MakeWire([Edge_12, Edge_7, Edge_11, Edge_6, Edge_1,Edge_4])
16 # make fillet at given wire vertices with giver radius
17 Fillet_1D_1 = geompy.MakeFillet1D(Wire_1, 55, [3, 4, 6, 8, 10])
18 
19 id_Wire_1 = geompy.addToStudy(Wire_1, "Wire_1")
20 id_Fillet_1D_1= geompy.addToStudy(Fillet_1D_1, "Fillet_1D_1")
21 
22 # display disks
23 gg.createAndDisplayGO(id_Wire_1)
24 gg.createAndDisplayGO(id_Fillet_1D_1)

Download this script


Fillet

1 # Fillet
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 radius = 10.
10 ShapeTypeEdge = geompy.ShapeType["EDGE"]
11 
12 # create vertices and vectors
13 p0 = geompy.MakeVertex( 0., 0., 0.)
14 px = geompy.MakeVertex(100., 0., 0.)
15 py = geompy.MakeVertex( 0., 100., 0.)
16 pz = geompy.MakeVertex( 0., 0., 100.)
17 vz = geompy.MakeVector(p0, pz)
18 vxy = geompy.MakeVector(px, py)
19 
20 # create an arc
21 arc = geompy.MakeArc(py, pz, px)
22 
23 # create a wire
24 wire = geompy.MakeWire([vxy, arc])
25 
26 # create a planar face
27 face = geompy.MakeFace(wire, 1)
28 
29 # create a prism
30 prism = geompy.MakePrismVecH(face, vz, 100.0)
31 
32 # get the list of IDs (IDList) for the fillet
33 prism_edges = geompy.SubShapeAllSortedCentres(prism, ShapeTypeEdge)
34 IDlist_e = []
35 IDlist_e.append(geompy.GetSubShapeID(prism, prism_edges[0]))
36 IDlist_e.append(geompy.GetSubShapeID(prism, prism_edges[1]))
37 IDlist_e.append(geompy.GetSubShapeID(prism, prism_edges[2]))
38 
39 # make a fillet on the specified edges of the given shape
40 fillet = geompy.MakeFillet(prism, radius, ShapeTypeEdge, IDlist_e)
41 
42 # make a fillet on all edges of the given shape
43 filletall = geompy.MakeFilletAll(prism, radius)
44 
45 # add objects in the study
46 id_prism = geompy.addToStudy(prism,"Prism")
47 id_fillet = geompy.addToStudy(fillet,"Fillet")
48 id_filletall = geompy.addToStudy(filletall,"Fillet all")
49 
50 # display the prism and the results of fillet operation
51 gg.createAndDisplayGO(id_prism)
52 gg.setDisplayMode(id_prism,1)
53 gg.createAndDisplayGO(id_fillet)
54 gg.setDisplayMode(id_fillet,1)
55 gg.createAndDisplayGO(id_filletall)
56 gg.setDisplayMode(id_filletall,1)

Download this script


Chamfer

1 # Chamfer
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 d1 = 10.
10 d2 = 10.
11 ShapeTypeFace = geompy.ShapeType["FACE"]
12 
13 # create vertices and vectors
14 p0 = geompy.MakeVertex( 0., 0., 0.)
15 px = geompy.MakeVertex(100., 0., 0.)
16 py = geompy.MakeVertex( 0., 100., 0.)
17 pz = geompy.MakeVertex( 0., 0., 100.)
18 vz = geompy.MakeVector(p0, pz)
19 vxy = geompy.MakeVector(px, py)
20 
21 # create an arc
22 arc = geompy.MakeArc(py, pz, px)
23 
24 # create a wire
25 wire = geompy.MakeWire([vxy, arc])
26 
27 # create a planar face
28 face = geompy.MakeFace(wire, 1)
29 
30 # create a prism
31 prism = geompy.MakePrismVecH(face, vz, 100.0)
32 
33 # get the list of IDs (IDList) for the chamfer
34 prism_faces = geompy.SubShapeAllSortedCentres(prism, ShapeTypeFace)
35 f_ind_1 = geompy.GetSubShapeID(prism, prism_faces[0])
36 f_ind_2 = geompy.GetSubShapeID(prism, prism_faces[1])
37 IDlist_f = [f_ind_1, f_ind_2]
38 
39 # perform a chamfer on the edges common to the specified faces
40 chamfer_e = geompy.MakeChamferEdge(prism, d1, d2, f_ind_1, f_ind_2)
41 
42 # perform a chamfer on all edges of the specified faces
43 chamfer_f = geompy.MakeChamferFaces(prism, d1, d2, IDlist_f)
44 chamfer_f1 = geompy.MakeChamfer(prism, d1, d2, ShapeTypeFace, IDlist_f)
45 
46 # perform a symmetric chamfer on all edges of the given shape
47 chamfer_all = geompy.MakeChamferAll(prism, d1)
48 
49 # add objects in the study
50 id_prism = geompy.addToStudy(prism,"Prism")
51 id_chamfer_e = geompy.addToStudy(chamfer_e,"Chamfer edge")
52 id_chamfer_f = geompy.addToStudy(chamfer_f,"Chamfer faces")
53 id_chamfer_f1 = geompy.addToStudy(chamfer_f1,"Chamfer faces 1")
54 id_chamfer_all = geompy.addToStudy(chamfer_all,"Chamfer all")
55 
56 # display the prism and the results of chamfer operation
57 gg.createAndDisplayGO(id_prism)
58 gg.setDisplayMode(id_prism,1)
59 gg.createAndDisplayGO(id_chamfer_e)
60 gg.setDisplayMode(id_chamfer_e,1)
61 gg.createAndDisplayGO(id_chamfer_f)
62 gg.setDisplayMode(id_chamfer_f,1)
63 gg.createAndDisplayGO(id_chamfer_f1)
64 gg.setDisplayMode(id_chamfer_f1,1)
65 gg.createAndDisplayGO(id_chamfer_all)
66 gg.setDisplayMode(id_chamfer_all,1)

Download this script


Extend Edge and Face

1 # Extend Edge and 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 p1 = geompy.MakeVertex( 0., 0., 0.)
12 p2 = geompy.MakeVertex(100., 100., 0.)
13 p3 = geompy.MakeVertex( 0., 100., 0.)
14 
15 # create edges
16 edge1 = geompy.MakeEdge(p1, p2)
17 edge2 = geompy.MakeCircleR(100)
18 
19 # create faces
20 face1 = geompy.MakePlaneThreePnt(p1, p2, p3, 200)
21 sphere1 = geompy.MakeSpherePntR(p1, 100)
22 faces2 = geompy.SubShapeAllSorted(sphere1, GEOM.FACE)
23 face2 = faces2[0]
24 
25 # perform edge extension
26 resEdge1 = geompy.ExtendEdge(edge1, 0.2, 0.8)
27 resEdge2 = geompy.ExtendEdge(edge1, -0.3, 1.3)
28 resEdge3 = geompy.ExtendEdge(edge2, 0.5, 1)
29 resEdge4 = geompy.ExtendEdge(edge2, 0.2, 0.5)
30 
31 # perform face extension
32 resFace1 = geompy.ExtendFace(face1, 0.2, 0.8, -0.3, 1.3)
33 resFace2 = geompy.ExtendFace(face1, 0, 0.5, 1, 2)
34 resFace3 = geompy.ExtendFace(face2, 0.2, 0.8, 0.3, 0.7)
35 resFace4 = geompy.ExtendFace(face2, 0.5, 1, 0.5, 1)
36 
37 # add objects in the study
38 id_edge1 = geompy.addToStudy(edge1, "Edge 1")
39 id_edge2 = geompy.addToStudy(edge2, "Edge 2")
40 id_face1 = geompy.addToStudy(face1, "Face 1")
41 id_face2 = geompy.addToStudy(face2, "Face 2")
42 id_resEdge1 = geompy.addToStudy(resEdge1, "Extended Edge 1")
43 id_resEdge2 = geompy.addToStudy(resEdge2, "Extended Edge 1")
44 id_resEdge3 = geompy.addToStudy(resEdge3, "Extended Edge 2")
45 id_resEdge4 = geompy.addToStudy(resEdge4, "Extended Edge 3")
46 id_resFace1 = geompy.addToStudy(resFace1, "Extended Face 1")
47 id_resFace2 = geompy.addToStudy(resFace2, "Extended Face 2")
48 id_resFace3 = geompy.addToStudy(resFace3, "Extended Face 3")
49 id_resFace4 = geompy.addToStudy(resFace4, "Extended Face 4")
50 
51 # display the prism and the results of chamfer operation
52 gg.createAndDisplayGO(id_edge1)
53 gg.setDisplayMode(id_edge1, 1)
54 gg.createAndDisplayGO(id_edge2)
55 gg.setDisplayMode(id_edge2, 1)
56 gg.createAndDisplayGO(id_face1)
57 gg.setDisplayMode(id_face1, 1)
58 gg.createAndDisplayGO(id_face2)
59 gg.setDisplayMode(id_face2, 1)
60 gg.createAndDisplayGO(id_resEdge1)
61 gg.setDisplayMode(id_resEdge1, 1)
62 gg.createAndDisplayGO(id_resEdge2)
63 gg.setDisplayMode(id_resEdge2, 1)
64 gg.createAndDisplayGO(id_resEdge3)
65 gg.setDisplayMode(id_resEdge3, 1)
66 gg.createAndDisplayGO(id_resEdge4)
67 gg.setDisplayMode(id_resEdge4, 1)
68 gg.createAndDisplayGO(id_resFace1)
69 gg.setDisplayMode(id_resFace1, 1)
70 gg.createAndDisplayGO(id_resFace2)
71 gg.setDisplayMode(id_resFace2, 1)
72 gg.createAndDisplayGO(id_resFace3)
73 gg.setDisplayMode(id_resFace3, 1)
74 gg.createAndDisplayGO(id_resFace4)
75 gg.setDisplayMode(id_resFace4, 1)

Download this script