Hi there,
I'm having trouble writing an add on in which I need the centroid of a face in world co-ordinates. It seems that any transformation that has been applied to the body is not taken into account. Is there a way to at least obtain the transform of a BRepBody once it has been moved? I could use this to transform the point to world space.
Alternatively is there a solution to obtaining vertices that are part of a body in world space?
Solved! Go to Solution.
Solved by BrianEkins. Go to Solution.
Solved by goyals. Go to Solution.
Is centroid property on BRepFace not returns the value in world coordinates? Please take a look at http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-801B5FF8-3BA8-48A0-8796-BBB329CDE1D0.
I don't think so, when I run it on a body that has been moved, I get the same coordinates back as before the move.
Position information from a BRepBody, and most objects, are returned relative to the coordinate system of the component that owns that entity. I'm guessing you want to get the coordinate relative to the root component. If the body owned by the root component, then it coordinates will always be in root coordinate space. If you've created a new component and the body is in that component, coordinates for that body will be returned relative to that component's coordinate system. There are a couple of ways to get the coordinate with respect to the root component.
Let's look at an example.
What we have now is the component named "Test" that contains a single BRepBody. There are two occurrences that reference that component. There's only one body but you're seeing two in the assembly. Moving the occurrences around in the assembly doesn't affect the body or the component. Through the API, if you get the BRepBody of the block and query coordinate information it will be returned relative to the "Test" component. However, if the user selects a face on the body, a proxy of the BRepFace is returned. The BRepFace proxy returns coordinate information as if the face exists in the root component. If you don't want the user to select the face, you can create a proxy by using the createForAssemblyContext method on the face. You need to pass in the occurrence you want to create the proxy relative to. In the example above, there are two instances of the real face and you have to tell it which of the two you want to create the proxy for.
The other approach is to get the points in the component space and then apply the occurrence transform to the coordinate to get it in root coordinate space. Create the proxy is easier.
Hello,
Thank you for your replies! The examples have helped me to get positions relative to moved components and understand occurrences better.
I'm actually going to have to apologize, I believe the centroids co-ordinates are returned in world space I just got confused because the units appear to be cm? Is this the default unit type for scripting in fusion 360?
The internal units of Fusion are centimeters so that's what the API uses. You can read more about it here.
http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-A81B295F-984A-4039-B1CF-B449BEE893D7
Can't find what you're looking for? Ask the community or share your knowledge.