Book a Demo

Author Topic: Selected Objects in Diagram  (Read 3307 times)

damien

  • EA User
  • **
  • Posts: 41
  • Karma: +0/-0
    • View Profile
Selected Objects in Diagram
« on: May 22, 2008, 06:21:04 pm »
Hello,

I would know how can i know the type of the objects in the diagram.SelectedObjects collection. I thinks the type is depending of the selected objects but when i try to cast it, i got an error.

I try to enable/diseable a item menu depending of the type of selected objects. But i don't success to use the returned objects of the collection
My code is :


Dim Element as EA.Element

' ....

 If MenuName = "-&Graal" And ItemName = "&Regrouper les tâches" Then
  For Each Element In Diagram.SelectedObjects
    If Element.Metatype <> "Task"
      IsEnabled = False
      Exit Sub
    End If  
  Next
  IsEnabled = True

' ....

How can get the selected objects and how can i know its type?

Thanks you
Bye
« Last Edit: May 22, 2008, 06:28:19 pm by damien »

damien

  • EA User
  • **
  • Posts: 41
  • Karma: +0/-0
    • View Profile
Re: Selected Objects in Diagram
« Reply #1 on: May 22, 2008, 06:47:17 pm »
I find the type of the object in the diagram.selectedObjects collection, its type is DiagramObject, it's logic but not explain in the help
« Last Edit: May 22, 2008, 06:47:41 pm by damien »

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Selected Objects in Diagram
« Reply #2 on: May 22, 2008, 10:49:34 pm »
The selected 'thing' is the picture of the element on the diagram. You need to obtain a reference to the actual element that the diagram object represents. You can do this by using the ElementID property of the diagram object.

Remember that the ObjectType enumeration does not uniquely identify every element type - use cases for example - because they are all elements. [So a use case would simply report its type as element.] You should read the Type property of the element to determine its type. You might also need to decode the SubType property depending on your specific needs.

David
No, you can't have it!