Find any interferance with active objects and only one 'tool' object.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I was searching for a while for an api focused version of this question(Finding Intersecting or Overlapping Bodies and Components) that is really only worried about a specific body. Essentially I was looking to implement a version of an extrude and so I want to know what bodies in the scene a specific object happens to overlap with. I have not seen any version which is focuses on only one objects interaction with others, instead it seems to be all objects overlapping.
I originally wanted it to just look for any intersection with any active objects in the scene, but I figured, with how quickly scenes can scale up, and the interference tool not being optimised for this specific case, it was best to keep the scope down. Currently my solution is to take bodies connected to the objects im "extruding"(I end up creating seperate objects i use the combine feature with) and run the interference calc on all of them and then filter the results based on if the cutting tool is one of the interference objects in each result. This seems very obtuse for what im trying to do and it does not allow for the "extrudes" to cut objects that it did not originally create them. Are there any better methods of doing this that I have overlooked? I have yet to find much information on doing this sort of stuff.
Additionally, if anyone else is looking for how to do it, my code is below. A quick note on it, utils.Collections.join is just a function that creates an objectcollection from multiple iterable objects and utils.Items is a function that just returns a list of the items in a collection which are properly type hinted (bracket access does not type hint the return, instead collection.item() would be used) so those functions are really just to make my life easier and dont change how the code works.
def findIterferances(targetBodies:'list[adsk.fusion.BRepBody]', toolBodies:'list[adsk.fusion.BRepBody]'):
interferanceCollection = utils.Collections.join(targetBodies,toolBodies)
interferanceInput = design.createInterferenceInput(interferanceCollection)
interferanceResults = utils.Items(design.analyzeInterference(interferanceInput))
ToolIntersections:'list[adsk.fusion.BRepBodies,adsk.fusion.BRepBodies]' = []
for result in interferanceResults:
if result.entityOne in toolBodies: ToolIntersections.append((result.entityOne,result.entityTwo))
elif result.entityTwo in toolBodies: ToolIntersections.append((result.entityTwo,result.entityOne))
return ToolIntersections