LightBulbOn the Root Component

LightBulbOn the Root Component

kandennti
Mentor Mentor
447 Views
2 Replies
Message 1 of 3

LightBulbOn the Root Component

kandennti
Mentor
Mentor

Hi there.

 

This is not a state that happens very often, but is there any way to determine if the root component is visible?

1.png

 

If it is an occurrence, I can determine this with the isLightBulbOn property, but I don't think the root component is applicable. I also checked the design object but could not find it.

0 Likes
448 Views
2 Replies
Replies (2)
Message 2 of 3

kandennti
Mentor
Mentor

Here is the only way I found.

# Fusion360API Python

import traceback
import adsk.fusion
import adsk.core

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

        print(isLightBulbOn_RootComp())

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

def isLightBulbOn_RootComp():
    app: adsk.core.Application = adsk.core.Application.get()

    sels: adsk.core.Selections = app.userInterface.activeSelections
    sels.clear()

    root: adsk.fusion.Component = app.activeProduct.rootComponent
    sels.add(root)

    res = app.executeTextCommand(u'VO.CheckPathVisibility')
    sels.clear()

    return res.split('.')[0].upper() == 'TRUE'


I would like to avoid it if possible, because it uses text commands and requires selection.

Message 3 of 3

BrianEkins
Mentor
Mentor

Ideally, the Component object should support the isLightBulbOn property, but it will only apply for the root component. All other "components" that are displayed are accessed through an Occurrence, which controls whether it is displayed or not, so the Occurrence.isLightBulbOn property would be used for them, not the component.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes