Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create New Component Using API

1 REPLY 1
Reply
Message 1 of 2
isocam
1465 Views, 1 Reply

Create New Component Using API

Can anybody help???

 

Is it possible, using Fusion 360 API, to capture the "Create New Component" function?

 

At present, I have to manually input a name for the new component. If the assembly is, for example, 1000 every time I right mouse click "Create New Component", can the part number be the assembly number + 1.

 

For example,

 

1000

 

Part Numbers 1000-001, 1000-002, 1000-003 etc

 

Many thanks in advance!!!!

 

Darren

1 REPLY 1
Message 2 of 2
marshaltu
in reply to: isocam

Hello,

 

The following sample demonstrates how to create new component and set "name" or "part number" by API.

 

Thanks,

Marshal

 

import adsk.core, adsk.fusion, traceback

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

    design = adsk.fusion.Design.cast(app.activeProduct)
    root = design.rootComponent
    
    for i in range(10):
        occ = root.occurrences.addNewComponent(adsk.core.Matrix3D.create())
        occ.component.name = 'My Component{}'.format(i)

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


Marshal Tu
Fusion 360 Developer
Autodesk, Inc.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report