The environments aren't directly exposed through the API. However, you can access the environment command through the API and interact with it to get and set the current environment. Below is some example code that contains a test function and two helper functions that let you get and set the environment. When getting and setting which item in the list is active, I chose to use the index instead of the name so it will work when Fusion is set to any language.
def run(context):
app: adsk.core.Application = adsk.core.Application.get()
ui = app.userInterface
try:
SetEnvironment(ui, 'Dark Sky')
envName = GetEnvironment(ui)
app.log(envName)
SetEnvironment(ui, 'Tranquility Blue')
envName = GetEnvironment(ui)
app.log(envName)
except:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
def GetEnvironment(ui: adsk.core.UserInterface) -> str:
viewCmd = ui.commandDefinitions.itemById('ViewEnvCommand')
listCntrl: adsk.core.ListControlDefinition = viewCmd.controlDefinition
if listCntrl.listItems[0].isSelected:
return 'Dark Sky'
elif listCntrl.listItems[1].isSelected:
return 'Grey Room'
elif listCntrl.listItems[2].isSelected:
return 'Photo Booth'
elif listCntrl.listItems[3].isSelected:
return 'Tranquility Blue'
elif listCntrl.listItems[4].isSelected:
return 'Infinity Pool'
elif listCntrl.listItems[5].isSelected:
return 'River Rubicon'
else:
return 'Unknown'
---------------------------------------------------------------
Brian EkinsInventor and Fusion 360 API Expert
Website/Blog:
https://EkinsSolutions.com