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:

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

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:

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:

Script and example project attached.