Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Object Visibility Control

jsormaz
Advocate

Object Visibility Control

jsormaz
Advocate
Advocate

Is there a way to control the following through the API? 

 

jsormaz_0-1718674058083.png

 

Instagram:
@sonsofsormaz
0 Likes
Reply
Accepted solutions (1)
313 Views
2 Replies
Replies (2)

j4n.vokurka
Advocate
Advocate
Accepted solution

Hello,

unfortunately, there is no direct object in the API that you could use to edit these settings. However you can simulate navigating through the user interface and set the checkboxes to your liking. I used this workaround technique for effects of the camera. 

This is a sample script that turns off sketches (unchecks the checkbox):

 

import adsk.core, adsk.fusion, adsk.cam, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        
        command_definitions = ui.commandDefinitions
        objectVisibilityCmdDef = command_definitions.itemById("VisibilityOverrideCommand")

        objectVisibilityControl = objectVisibilityCmdDef.controlDefinition
        objectVisibilityList = adsk.core.ListControlDefinition.cast(objectVisibilityControl)

        sketchesCheckBox = objectVisibilityList.listItems.item(8)  # turn off sketches

        if sketchesCheckBox.isSelected:
            was_turned_off = sketchesCheckBox.isSelected = False

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

 

 

1 Like

jsormaz
Advocate
Advocate

good enough for me, thanks!

Instagram:
@sonsofsormaz
0 Likes