Cobb
Cobb

Reputation: 5

What type should I use to create a component instance with the enterprise architect API?

Hello I am trying to create a component instance with the enterprise architect api, only the type I provided "ComponentInstance" does not exist, so I had the "Invalid Type" error. So I have to consult the "Automation.pdf" documentation but among the list of types I don't know which one I should use, should I take the same type that I use when I create a component (type "Component" )? Thank you in advance for any advice

Upvotes: 0

Views: 152

Answers (1)

qwerty_so
qwerty_so

Reputation: 36295

I just ran a short test:

p = rep.getPackageByGUID("{1315AC6B-7102-4ddb-B189-1D453CA4C050}") # get the target package
classifier = rep.getElementByGUID("{2CB23871-A0EF-47ab-B81A-0A60977091F0}") # get the classifier element
comp = p.elements.addNew("test", "Component") # add a new component
comp.classifierId = classifier.elementId # adding the classifier makes it an instance
comp.update # save to database

It's Python rather than C# but the API is the same.

You can verify that component instances are made this way by dragging a component over to a diagram "As Instance". You will note that it's another ordinary component, but classified with the component from where you dragged over.

Upvotes: 1

Related Questions