I'm trying to use PythonOCC to read in wireframe data (see this link) that is in IGES or STEP format, for eventual use in building a FE beam-element model.
Where in PythonOCC can I actually extract properties about edges and curves? I've built this sample that prints out all vertices in a file:
from OCC.Extend.DataExchange import read_iges_file
from OCC.Core.TopExp import (TopExp_Explorer,
topexp_MapShapesAndAncestors,
topexp_FirstVertex,
topexp_LastVertex)
from OCC.Core.TopAbs import *
from OCC.Core.TopoDS import TopoDS_Shape, topods
from OCC.Core.BRep import BRep_Tool, BRep_Tool_Pnt, BRep_Tool_IsGeometric, BRep_Tool_Parameter, BRep_Tool_Curve
from OCC.Core.BRepAdaptor import BRepAdaptor_Curve
from OCC.Core.GeomTools import GeomTools_CurveSet
shape = read_iges_file('tubes.iges')
topExp = TopExp_Explorer()
topExp.Init(shape, TopAbs_EDGE)
def print_vertex(va):
print(BRep_Tool().Pnt(va).Coord(1), BRep_Tool().Pnt(va).Coord(2), BRep_Tool().Pnt(va).Coord(3))
while topExp.More():
edge = topExp.Current()
first, last = topexp_FirstVertex(edge), topexp_LastVertex(edge)
curv = BRepAdaptor_Curve(edge).Curve()
print_vertex(first)
print_vertex(last)
topExp.Next()
print()
That said, what I really want is to know if a curve is a line versus an arc, and if it's an arc, what the centerpoint and radius are.
I am trying to do something similar. If this can be useful, I am using the following snippet to get the type of a Curve and then extracting vertices: