Book a Demo

Author Topic: Copying elements  (Read 4311 times)

rahul

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Copying elements
« on: January 25, 2011, 11:46:36 am »
Hello,
I want to create a addin in which after drag and drop the element from project browser to diagram plain(source element),the diagram and its child objects should be copied to the source element.

TIA
Rahul

Colin Richardson

  • EA User
  • **
  • Posts: 52
  • Karma: +0/-0
    • View Profile
Re: Copying elements
« Reply #1 on: January 25, 2011, 03:11:29 pm »
Have a look at Repository.GetTreeSelectedElements, Diagram.DiagramObjects.AddNew and EA_OnPostNewDiagramObject.

IMHO, this could be tricky.  It might be easier to create an "Add Child Elements to Diagram" add-in (i.e. via the Add-Ins menu) and not rely on the OnPostNewDiagramObject event

~ Colin

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Copying elements
« Reply #2 on: January 25, 2011, 05:26:45 pm »
This topic might be of help.

Geert

rahul

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Copying elements
« Reply #3 on: February 04, 2011, 11:40:23 am »
Thanks for the inputs.
But I was stuck in knowing which method will give us the PackageId of the Destination Package where we are droping the element.

all the elements are getting copied to the diagram plain of the destination package but how to copy the same in the Project Browser also

TIA
Rahul

Colin Richardson

  • EA User
  • **
  • Posts: 52
  • Karma: +0/-0
    • View Profile
Re: Copying elements
« Reply #4 on: February 04, 2011, 01:09:28 pm »
Something like:

var element = repository.GetTreeSelectedElement();

if (element != null)
     var packageId = element.PackageID;