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.
- Create a new assembly.
- Create a new component named "Test". In the browser it will be listed as "Test:1" because it's the first instance of the component "Test".
- Add a box primitive to the new component. In the browser, you should see it under the "Test:1" occurrence.
- Select "Test:1" in the browser and do a copy-paste operation to create a second occurrence of the component "Test". It will show up in the browser as "Test:2".
- Move both "Test:1" and "Test:2" around in the assembly.
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.
---------------------------------------------------------------
Brian EkinsInventor and Fusion 360 API Expert
Website/Blog:
https://EkinsSolutions.com