The result I want is this:
Archived discussion
Get vertices coordinates on an edge
I have this function:
shape = read_step_file(input_path)
t = TopologyExplorer(shape)
edges = []
for edge_idx, edge in enumerate(t.edges()):
d = {'edge': edge,
'edge_index': edge_idx,
'vertices_coordinates': []}
vertices = t.vertices_from_edge(edge)
for i, vertice in enumerate(vertices):
c = vertice.DumpJsonToString()
c = '{' + c + '}'
data = json.loads(c)
point = data["TShape"]["Pnt"]['gp_Pnt']
d['vertices_coordinates'].append(point)
edges.append(d)
return edges
But this code doesn't give me the global coordinates, only the local ones.
I draw the edges and the shape, and they don't match.
The result is in the attachment.
How to get the global?
Discussion
2 archived replies
Posts are displayed in their archived order.
Hi Author,
I'm not sure about local and global, but this is how i get vertex coordinates of an edge:
from OCC.Extend.TopologyUtils import TopologyExplorer
from OCC.Core.BRep import BRep_Tool
for vertex in TopologyExplorer(edge, ignore_orientation=True).vertices():
point = BRep_Tool().Pnt(vertex)
coordinates = [point.X(), point.Y(), point.Z()]