Book a Demo

Author Topic: Drop Element to Diagram and Create a new Element  (Read 8076 times)

Ceronimo

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Drop Element to Diagram and Create a new Element
« on: April 07, 2016, 11:16:16 pm »
Hi i want to drop an Element(Class) from the ProjectTree into a diagram.
And i want that a copy is created from the choosen Element into the package of the diagram

so far iwrote this

int iddiagram = int.Parse(Info.Get("DiagramID").Value);
            int idelement = int.Parse(Info.Get("ElementID").Value);
            int packageid=Repository.GetDiagramByID(iddiagram).PackageID;

            EA.Element aElement=Repository.GetElementByID(idelement);
            EA.Package aPackage=Repository.GetPackageByID(packageid);

     
            aElement=aPackage.Elements.AddNew(aElement.Name,aElement.Type);

but how can i realize this drag and drop ?

Ceronimo

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Drop Element to Diagram and Create a new Element
« Reply #1 on: April 07, 2016, 11:18:13 pm »
i dont know how to get the id`s from both

i saw this

EA_OnPreDropFromTree(EA.Repository Repository, EA.EventProperties Info)

but i dont know how this Event works  and which id it gives to me

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Drop Element to Diagram and Create a new Element
« Reply #2 on: April 07, 2016, 11:21:52 pm »
Yes, that is the one you need.

Is there something in the manual that is not clear for you?

Geert

Ceronimo

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Drop Element to Diagram and Create a new Element
« Reply #3 on: April 07, 2016, 11:35:51 pm »
I have to doucments
one i bought Scripting ea.
the other one is the sdk documentation.

and ive searched now 2-3 hours i used search in Adobe but i dont find anything.
if i ssearch the Event in Google it is the same.

Can you please give me a link how to use this Event.

Or an example ?

Greetz Ceronimo

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller

Ceronimo

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Drop Element to Diagram and Create a new Element
« Reply #5 on: April 07, 2016, 11:49:41 pm »
thanks a lot
 ;D ;D ;D ;D

Ceronimo

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Drop Element to Different Packages(root,view,package)
« Reply #6 on: April 13, 2016, 03:39:45 pm »
Do somebody know how can i make a difference between  TheRoot(Package), Views(Packages), Packages.
if i try to get just packages f.e. with the objectType: otPackage, it picks all of them.
But i want to get them seperatly.

Because i want to drop Elements from a Root Package (mylibrary) to a view View Package or normal Package and i want my Plugin to recognize if the dropped Package(is an other root, view or package.


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Drop Element to Diagram and Create a new Element
« Reply #7 on: April 13, 2016, 03:51:21 pm »
The root packages don't have a .Element, and have a ParentID of 0
The views have a parent package which is a root.
Regular packages don't have a root for parent.

Geert

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: Drop Element to Diagram and Create a new Element
« Reply #8 on: April 13, 2016, 03:57:00 pm »
Hi,

I'm not sure I got your question.

If you have a package you can determine by ParantId:
- if it has no parent package than it's the root
- if it has the root package as a parent than it is a view
- else

In Example scripts (Scripting Window) you find examples how to navigate through packages, find root package, nested packages and so on.

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

Ceronimo

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Drop Element to Diagram and Create a new Element
« Reply #9 on: April 13, 2016, 04:30:16 pm »
F.e. Root -->View-->Package1-->Package1.1

the Parentid of Package1.1 is Package1
i Want to check if it is a normal Package or View Package ?


Ceronimo

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Drop Element to Diagram and Create a new Element
« Reply #10 on: April 13, 2016, 04:42:22 pm »
Problem solved !