How to get the corners of a BRep Body

How to get the corners of a BRep Body

Anonymous
Not applicable
1,044 Views
2 Replies
Message 1 of 3

How to get the corners of a BRep Body

Anonymous
Not applicable

Is there a way to get the coordinates of all the corners of a BRep body?
For example, if I have a 3D hexagon, can I get the coordinates of all 12 corners?

0 Likes
Accepted solutions (1)
1,045 Views
2 Replies
Replies (2)
Message 2 of 3

ekinsb
Alumni
Alumni

"Corners" on a solid model are represented by BRepVertex objects.  For a 3D hexagon there would be 12 vertices.  The BRepVertex object supports a geometry property which returns a Point3D object that will give you the position of the vertex.  You can read more about solids and vertices here: http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-1C3FFADB-52C4-49BB-8981-4A448FFE4442.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

Hey @Anonymous

 

you will start with a BRepBody firstBRepBody, a BRepBody has BRepFaces. A BRepFace has vertices. A Vertex is a Point3D object. On a Point3D object you can use .geometry.x or .geometry.asArray() to get the coordinates of the point you are looking for.

 

firstFaces = [] #Array of Array of Vertices [[Point3D_1,Point3D_2,Point3D_3,Point3D_4],[Point3D_1,Point3D_2,Point3D_3,Point3D_4],...]

#iterate all faces of a BRepBody calles firstBRepBody
for i in range(0,firstBRepBody.faces.count):
    firstVertices = []
    #iterate all Vertices (Points3D) of a face 
    for j in range(0, firstBRepBody.faces.item(i).vertices.count):
        #add vertices of a face to an array
        firstVertices.append(firstBRepBody.faces.item(i).vertices.item(j)) 
        #firstBRepBody.faces.item(i).vertices.item(j).geometry.x would be the x-coordinate of a vertex
        #firstBRepBody.faces.item(i).vertices.item(j).geometry.asArray() returns xyz-coordinates as array
    #add array of vertices of a face to the face array
    firstFaces.append(firstVertices)

# ...
#now you could iterate through the array and get each vertex and then you can get the vertex geometry
x = firstVertex.geometry.x
y = firstVertex.geometry.y
z = firstVertex.geometry.z

 I hope that helps, cheers Fabi