2013-02-12 17:35:16 +06:00
|
|
|
# Add Point on Edge
|
|
|
|
|
|
|
|
import salome
|
2021-08-12 11:43:44 +05:00
|
|
|
salome.salome_init_without_session()
|
2013-04-04 13:06:43 +06:00
|
|
|
import GEOM
|
|
|
|
from salome.geom import geomBuilder
|
2017-06-13 14:57:14 +05:00
|
|
|
geompy = geomBuilder.New()
|
2013-02-12 17:35:16 +06:00
|
|
|
|
2014-10-21 22:06:51 +06:00
|
|
|
# Variant 1: using DivideEdge()
|
|
|
|
|
2013-02-12 17:35:16 +06:00
|
|
|
# create vertices
|
|
|
|
p1 = geompy.MakeVertex(0,0,50)
|
|
|
|
p2 = geompy.MakeVertex(60,0,50)
|
|
|
|
|
|
|
|
# make an edge
|
|
|
|
edge = geompy.MakeEdge(p1, p2) #geompy.GetSubShape(box, edge_ind)
|
|
|
|
|
|
|
|
# divide an edge
|
|
|
|
divide = geompy.DivideEdge(edge, -1, 0.5, 0)
|
|
|
|
|
|
|
|
# add objects in the study
|
|
|
|
id_edge = geompy.addToStudy(edge, "Edge")
|
|
|
|
edge_points = geompy.SubShapeAllSortedCentres(edge, geompy.ShapeType["VERTEX"])
|
|
|
|
for point in edge_points:
|
|
|
|
geompy.addToStudyInFather(edge, point, "Edge's point")
|
|
|
|
|
|
|
|
id_divide = geompy.addToStudy(divide, "Divided edge")
|
|
|
|
edge_points = geompy.SubShapeAllSortedCentres(divide, geompy.ShapeType["VERTEX"])
|
|
|
|
for point in edge_points:
|
|
|
|
geompy.addToStudyInFather(divide, point, "Edge's point after divide")
|
|
|
|
|
2014-10-21 22:06:51 +06:00
|
|
|
|
|
|
|
# Variant 2: using DivideEdgeByPoint()
|
|
|
|
|
|
|
|
box = geompy.MakeBox(0,0,0, 10,10,10, theName="box")
|
2014-12-10 21:07:28 +05:00
|
|
|
p1 = geompy.MakeVertex( 3, -2, 1, theName="point 1 to project" )
|
|
|
|
p2 = geompy.MakeVertex( 7, -2, 1, theName="point 2 to project" )
|
|
|
|
edge = geompy.GetEdgeNearPoint( box, p1, theName="edge to split")
|
2014-10-21 22:06:51 +06:00
|
|
|
|
2014-12-10 21:07:28 +05:00
|
|
|
div = geompy.DivideEdgeByPoint( box, edge, [p1, p2], theName="box (edge divided)")
|
2014-10-21 22:06:51 +06:00
|
|
|
|
|
|
|
|
2017-06-13 14:57:14 +05:00
|
|
|
salome.sg.updateObjBrowser()
|