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: 

Show hide body FROM setup

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
JYZMT
436 Views, 2 Replies

Show hide body FROM setup

Hello all

I've got a complicated model with a lot of components. I'm going through and checking machining setups that have already been... well, set up. I'm constantly scrolling up and down the browser, and its killing me - the list is so long. I have to turn on a component or body, scroll down to the setup, check it, scroll back up, hide it, and then move on to the next one. I can't find a way to show/hide from the set up? 

So I wondered if its possible to write simple script button toggle, that turns on all bodies (and their parent component holders) for the set up you are in? (assuming the bodies are in the setup>model, which for me they are) 

This way, I can turn everything off, go to a set up, toggle the geometry I'm checking on or off. 

Dooable? 

Thank for any help

2 REPLIES 2
Message 2 of 3
BrianEkins
in reply to: JYZMT

I was curious about this and created the script below to test it.  It certainly needs some error handling and also likely needs some more work to handle various cases but it worked in my simple case.  To use it, just activate the setup you want and then run the script.  If it works correctly, the only bodies displayed should be those used by the setup.

def run(context):
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        cam = adsk.cam.CAM.cast(app.activeProduct)

        # Turn off the display of all bodies.
        for setup in cam.setups:
            for model in setup.models:
                if isinstance(model, adsk.fusion.BRepBody):
                    model.isLightBulbOn = False

        setup = adsk.cam.Setup.cast(None)
        for setup in cam.setups:
            if setup.isActive:
                for model in setup.models:
                    if isinstance(model, adsk.fusion.BRepBody):
                        model.isLightBulbOn = True
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) 

 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 3
JYZMT
in reply to: BrianEkins

Great, Thank you. I'll try it.

I hope others also find it useful, maybe it will find its way into fusion as a default command!

Thanks again, I'll let you know if I hit any problems with it.  

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