Object Visibility Control

Object Visibility Control

jsormaz
Advocate Advocate
510 Views
2 Replies
Message 1 of 3

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
Accepted solutions (1)
511 Views
2 Replies
Replies (2)
Message 2 of 3

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()))

 

 

 

Message 3 of 3

jsormaz
Advocate
Advocate

good enough for me, thanks!

Instagram:
@sonsofsormaz
0 Likes