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 component & get ID

2 REPLIES 2
Reply
Message 1 of 3
lukepighetti
281 Views, 2 Replies

Create component & get ID

Hi there,

 

How do I create a component and get the ID for it?

 

Thanks

Luke

2 REPLIES 2
Message 2 of 3
ekinsb
in reply to: lukepighetti

I'm not sure what you mean by "ID" but each component does have a name which you can see and edit in the browser.  That's exposed in the API through the name property of the Component object.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 3

I know it's really old but I landed here looking for the same answer.

 

// Get the root component of the active design.
var rootComponent = design.rootComponent;

// Create a new occurrence.
var trans = adsk.core.Matrix3D.create();
var newOccurrence = rootComponent.occurrences.addNewComponent(trans);

// Get the associated component.
var newComponent = newOccurrence.component;

// get the name
var newComponentName = newComponent.name

// and message the new component name
ui.messageBox('New component name is: ' + newComponentName);

 

 

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