Book a Demo

Author Topic: Instance creation of an element  (Read 5227 times)

ALL_IN_ONE

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Instance creation of an element
« on: July 08, 2009, 11:35:17 pm »
Hello Folks,

I can create  a diagram object of an element for eg let us consider an element of type "component" using API's. But it creates a "Simple Link". But my aim is to create an "Instance of that Element(Object)" using automation(API's). Can anybody help me?

ALL_IN_ONE

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Re: Instance creation of an element
« Reply #1 on: July 13, 2009, 04:51:11 pm »
Dear folks,

To further inform you all about my issue I have uploaded the snapshot in the below link, of what exactly I am looking for.

http://picasaweb.google.com/lh/photo/HbuClw7JvxQcLnMN3HqBPw?authkey=Gv1sRgCIWdyYjWkPyD3QE&feat=directlink

The yellow outline on the diagram object is a simple link whereas the one in red line creates and instance of component XYZ.

Thus I am not able to create an instance of XYZ which should be another element as shown on the structure in red outline.

Do let me know if anybody has any idea or hint on how to go about it

regards,
coder

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Instance creation of an element
« Reply #2 on: July 13, 2009, 04:57:06 pm »
Hold down the control button when dragging the element onto the diagram.
That should make the diagog appear giving you the choice to create a simple link, an instance, or a new child.


Geert
Edit:
Sorry I didn't read your question properly  ::)
I see this is answerred properly now.
« Last Edit: July 13, 2009, 05:35:48 pm by Geert.Bellekens »

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Instance creation of an element
« Reply #3 on: July 13, 2009, 05:04:01 pm »
To create an instance of a component - create a new "Component" Element and set the ClassifierID to the ElementID of the appropriate Component.

Example:

Code: [Select]
Set Component = [reference to original Component Element]
Set Package = Repository.GetPackageByID(Component.PackageID)
Set NewInstance = Package.Elements.AddNew("", "Component")
NewInstance.ClassifierID = Component.ElementID
NewInstance.Update
Hope this helps.

ALL_IN_ONE

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Re: Instance creation of an element
« Reply #4 on: July 13, 2009, 06:57:57 pm »
Hey Aaron,

Thanks a million. It works.

Best Regards,
Coder