Given an imported B-Rep, how can I do the following with the FreeCAD Python API:
1) Enumerate all Shells, Faces, Wires, Edges, and Vertices
2) Get the parametric description of each Shell/Face/Wire/Edge/Vertex
3) Get the adjacency info of each (i.e. how can I know which Faces are connected to which Wires)
Traversing the Entire B-Rep of a STEP file
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: Traversing the Entire B-Rep of a STEP file
Code: Select all
def info_subshapes(shape):
"""Print the list of subshapes of a shape.
info_subshapes(my_shape)
"""
sh = ["Solids",
"Compounds",
"CompSolids",
"Shells",
"Faces",
"Wires",
"Edges",
"Vertexes"]
print("-> Content of {}".format(shape.ShapeType))
for s in sh:
subs = shape.__getattribute__(s)
if subs:
if (len(subs) == 1) and (subs[0].isEqual(shape)):
pass # hide self
else:
print("{}: {}".format(s, len(subs)))
Re: Traversing the Entire B-Rep of a STEP file
How do I get a parametric description of each Face or Edge?
Re: Traversing the Entire B-Rep of a STEP file
What do you call parametric description ?
An Edge is the bounded portion of a geometric curve (Edge.Curve) between 2 parameters (Edge.FirstParameter, Edge.LastParameter).
A Face is a portion of a geometric surface (Face.Surface) bounded by wires (Face.Wires).
Each Wire is made of Edges (Wire.Edges) and the 2D parametric representation of such an edge is obtained by :
An Edge is the bounded portion of a geometric curve (Edge.Curve) between 2 parameters (Edge.FirstParameter, Edge.LastParameter).
A Face is a portion of a geometric surface (Face.Surface) bounded by wires (Face.Wires).
Each Wire is made of Edges (Wire.Edges) and the 2D parametric representation of such an edge is obtained by :
Code: Select all
curve2d, firstpar, lastpar = the_face.curveOnSurface(the_edge)