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: 

Speed of Analyze Interference compared to Cut/Intersect/Union features

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
nnamfoh
379 Views, 2 Replies

Speed of Analyze Interference compared to Cut/Intersect/Union features

In my plugin analyse the interference of bodies to inform the user if there model is likely to work (ie, a bolt isn't intersecting some geometry). 

 

To do this I need to quickly check interference across the design, which can be computationally expensive. From what I can see the quickest way to guess at this it test bounding boxes (way faster than complex bodies but obviously not accurate). After that I wonder what is faster.

 

The API  supports analysing interference (link below), and alternatively I could use basic combine features like cut and intersect to get similar results. In the end I want to do the latter since I want the user to be able to visualize the flaws and analysing interference doesn't output anything to see. 

 

Is analysing interference significantly faster that using combineFeatures? If its significantly faster (ie order of magnitude) it could be worth checking the design like that and narrowing what needs to go through combine process. Unfortunately the API never says how fast I could expect anything to be. Does anyone know, or have a guess at the efficiency differences between these two methods?

 

Inteference Reference:

http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-613cb65c-61c3-11e5-9a1c-3417ebd3d5be

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

Using the analyzeInterference method and the capabilities already there is going to be much faster than trying to write this on your own; both from a standpoint of writing the code and in the execution of the program.  You can get information about the interference geometry.  The analyzeInterference returns transient BRepBody objects that you can query to get more information about the interferences and, as the program below demonstrates, you can also use these to create real bodies in the model.  However, creating bodies directly without building features is only supported in direct modeling documents or a base feature in a parametric document.  Creating bodies in a base feature is demonstrated below.

 

import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface

        design = adsk.fusion.Design.cast(app.activeProduct)
        
        # Get the root component of the active design
        rootComp = design.rootComponent
                
        # Create a collection of the bodies to check for interference
        inputBodies = adsk.core.ObjectCollection.create()
        for body in rootComp.bRepBodies:
            inputBodies.add(body)
        
        # Create the interferenceInput object and run the analysis.
        interferenceInput = design.createInterferenceInput(inputBodies)
        interferenceInput.areCoincidentFacesIncluded = False
        results = design.analyzeInterference(interferenceInput)    

        # Check to see if there were any interferences found.
        if results.count == 0:
            ui.messageBox('No interference found.')
        else:
            # Create a base feature containing the interference bodies.
            baseFeat = rootComp.features.baseFeatures.add()
            baseFeat.name = 'Inteference Results'
            baseFeat.startEdit()
            
            intResult = adsk.fusion.InterferenceResult.cast(None)
            for intResult in results:
                body = rootComp.bRepBodies.add(intResult.interferenceBody, baseFeat)
                body.name = 'Interference ' + body.name
            
            baseFeat.finishEdit()
                
            ui.messageBox(str(results.count) + ' interferences found.')
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 3
nnamfoh
in reply to: ekinsb

Wow thats much faster. I didn't realize that was how you could get around the non-parametric problem. 

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