Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get the corners of a BRep Body

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
jmperez6
772 Views, 2 Replies

How to get the corners of a BRep Body

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?

2 REPLIES 2
Message 2 of 3
ekinsb
in reply to: jmperez6

"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
Message 3 of 3

Hey @jmperez6

 

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

 

 

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report