API Bug occurrence.isLightBulbOn did not work properly

API Bug occurrence.isLightBulbOn did not work properly

akonovalenko
Contributor Contributor
843 Views
4 Replies
Message 1 of 5

API Bug occurrence.isLightBulbOn did not work properly

akonovalenko
Contributor
Contributor

Dear support, 

Could you please check the attached python script which demonstrates incorrect behavior of the occurrence.isLightBulbOn flag.

isLightBulbOn flag can not be set to False programmatically for the elements which parent has eye icon turned off in a Fusion Browser.
When I tried to set it to True(isLightBulbOn=True) the API change eye icon from 'on' to 'off' and from 'off' to 'on' on each API call instead of enabling eye icon.

Screenshot_2.png

844 Views
4 Replies
Replies (4)
Message 2 of 5

goyals
Autodesk
Autodesk

I understand it might be looking odd. The visibility of child components are dependent on parent component visibility. If parent component visibility is false then child component visibility is ignored.  

 

After you turn off visibility of parent component and query visibility of the child component then it is returning false but it is showing 'on' in browser which is right. Because of this difference it goes out of sync and you notice the behaviour what you mentioned in your post.  

 

I am not sure showing whether this property should give the status of the browser or in canvas because it still be confusing for some user whether they will see the component is invisible in canvas but this property is returning true, the status in browser. 

 

Thanks.



Shyam Goyal
Sr. Software Dev. Manager
Message 3 of 5

akonovalenko
Contributor
Contributor

The Occurrence Object has another attribute isVisible which response for it visibility in canvas https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-fbf29660-bff9-4062-93f8-1fcbe4b8c51c

and isLightBulbOn according to the documentation http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-203a9b47-df8f-4373-9535-b3df3d8e558f is about browser
"Gets and sets if the light bulb of this occurrence as displayed in the browser is on or off"

Message 4 of 5

alasdair_scott2DJBH
Observer
Observer

Sorry to necro an old post but this is absolutely broken and still is in 2025(!!!) and this is the only post I can find on the topic.

 

The occurrence.isLightBulbOn function is bugged and gives the same result as occurrence.isVisible. In other words, calling occurrence.isLightBulbOn on a child occurrence whose parent's light bulb is off, returns False regardless of the actual light bulb state of the child. What's more, when a attempting to use the function to set the state on a child occurrence whose parent's light bulb is off is also broken. When attempting this, occurrence.isLightBulbOn = False has no effect, as the original post describes, but also, occurrence.isLightBulbOn = True adopts a toggle behaviour and will switch false to to true and true to false depending on the starting state of the child. AAAAGGGGGGGHHHHHHHHHHH.
 
How is it possible for this to be so broken for so long and nobody care?
 
I'm running this python script on the latest version of Fusion: 
import traceback
import adsk.core
import adsk.fusion

# Initialize the global variables for the Application and UserInterface objects.
app = adsk.core.Application.get()
ui = app.userInterface


def run(_context: str):
    try:
        allOccurrences = app.activeProduct.rootComponent.allOccurrences
        msg = "Before!"

        for occurrence in allOccurrences:
            msg = msg + "\noccurance name: " + occurrence.name + "\noccurrence.isLightBulbOn = " + \
                str(occurrence.isLightBulbOn) + "\noccurrence.isVisible = " + \
                str(occurrence.isVisible)

        ui.messageBox(msg)

        for index, occurrence in enumerate(allOccurrences):
            if index % 2 != 0:
                occurrence.isLightBulbOn = True

        msg = "After!"

        for occurrence in allOccurrences:
            msg = msg + "\noccurance name: " + occurrence.name + "\noccurrence.isLightBulbOn = " + \
                str(occurrence.isLightBulbOn) + "\noccurrence.isVisible = " + \
                str(occurrence.isVisible)

        ui.messageBox(msg)
    except:
        ui.messageBox(f'Failed:\n{traceback.format_exc()}')

 

The above script iterates through all occurrences, logs the result of isLightBulbOn and isVisible and then displays those results in a message box. It then attempts to set isLightBulbOn to True on the odd numbered occurrences in the list (in this case it's one of the child occurrences). Finally it logs the isLightBulbOn and isVisible results again and displays another message box.

 

When I run it on a simple project with a parent component containing two child occurrences, with all eyes (light bulbs) manually switched on, the script runs as expected, no surprises:

alasdair_scott2DJBH_1-1748335905092.png

 

After the script has attempted to set isLightBulbOn to True, again no surprises:

alasdair_scott2DJBH_2-1748335935869.png

 

When running the script with just the parent light bulb manually switched off, here we see everything returns false when isLightBulbOn for the children should return True:

alasdair_scott2DJBH_3-1748336022034.png

And finally, after the script attempts to set isLightBulbOn = True on Component3:1, which was already set to true, you can see that it's actually flipped it to false:

alasdair_scott2DJBH_4-1748336189888.png

 

Script and example project attached.

0 Likes
Message 5 of 5

BrianEkins
Mentor
Mentor

I can reproduce this problem and will make sure a bug is logged.

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