Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: RoyClem on January 14, 2005, 09:02:58 am
-
In the Diagram class, there is a collection called SelectedObjects.
What is the type of the objects within it?
I tried casting to the Element type, but received an exception.
Thanks!
Roy
-
Apparently, SelectedObjects returns a DiagramObject.
Here's the code I used to retrieve the name of a selected element on a diagram.
Note, I pass the EA repository to the method as an argument.
EA.Diagram m_EADiagram =
m_EARepository.GetCurrentDiagram();
EA.Element m_EAElement = null;
EA.DiagramObject m_EADiagramObject;
for( short i = 0; i <
m_EADiagram.SelectedObjects.Count; i++ )
{
m_EADiagramObject = (EA.DiagramObject)
m_EADiagram.SelectedObjects.GetAt(i);
m_EAElement = m_EARepository.GetElementByID
(m_EADiagramObject.ElementID);
MessageBox.Show(m_EAElement.Name);
}