Author Topic: Diagram object to EA Element  (Read 901 times)

The apprentice

  • EA Novice
  • *
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Diagram object to EA Element
« on: May 09, 2018, 07:05:50 pm »
Hi,

I have a Diagram and I would like to manipulate elements/associations....

A DiagramObject has no name attribute and when I try to convert him to an EA.Element it does'nt work.

Code: [Select]
EA.Diagram diagram = (EA.Diagram)currentElement.CompositeDiagram;// retrieve the diagram in question
            DiagramObject obn = (EA.DiagramObject)diagram.DiagramObjects.GetByName("IMyMbd"); // Trigger an error on Enterprise Architect : "Action not suported". ( maybe because  an DiagramObject has no name ? )
            foreach(EA.DiagramObject ou in diagram.DiagramObjects)
            {
 
                    EA.Element element = (EA.Element)ou; // Trigger an error : "unable to cast COM object of type 'System.__ComObject' to interface type 'EA.Element'"
                   
            }

How can I retrieve an element wich represent a Diagram object.

Thank you

Nabil

  • EA User
  • **
  • Posts: 141
  • Karma: +5/-2
    • View Profile
    • View My LinkedIn Profile Here
Re: Diagram object to EA Element
« Reply #1 on: May 09, 2018, 07:20:44 pm »
EA.Element element = Rep.GetElementbyID(ou.ElementID);

will get the handle of element

BR
Nabil
Nabil