I got this work but only for one component at a time. I would to this to work on multiple selections...Is that possible?
import adsk.core
import adsk.fusion
import traceback
def run(context):
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = app.activeProduct
# Get the active selection in Fusion 360
selections = ui.activeSelections
if selections.count == 0:
ui.messageBox("No components selected. Please select one or more components.")
return
for selection in selections:
if isinstance(selection.entity, adsk.fusion.Occurrence):
component = selection.entity
part_name = component.name
# Update the Description to match the Part Name
component.component.description = part_name
ui.messageBox("Updated the Description for selected components.")
except:
if ui:
ui.messageBox("Error: " + traceback.format_exc())
if __name__ == "__main__":
run(None)
Hi @tookemtoni .
Try this.
# Fusion360API Python script
import traceback
import adsk.core as core
import adsk.fusion as fusion
def run(context):
ui: core.UserInterface = None
try:
app: core.Application = core.Application.get()
ui = app.userInterface
des: fusion.Design = app.activeProduct
comp: fusion.Component = None
for comp in des.allComponents:
comp.description = comp.name
ui.messageBox("Done")
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
@kandennti Done.... Thank you!