Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding

Show hide body FROM setup

JYZMT
Advocate Advocate
739 Views
2 Replies
Message 1 of 3

Show hide body FROM setup

JYZMT
Advocate
Advocate

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

0 Likes
Accepted solutions (1)
740 Views
2 Replies
Replies (2)
Message 2 of 3

BrianEkins
Mentor
Mentor
Accepted solution

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
1 Like
Message 3 of 3

JYZMT
Advocate
Advocate

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.  

0 Likes