Book a Demo

Author Topic: Syntax for selecting a diagram object  (Read 6361 times)

EXploringEA

  • EA User
  • **
  • Posts: 172
  • Karma: +8/-0
    • View Profile
Syntax for selecting a diagram object
« on: September 12, 2013, 07:01:46 pm »
I'm trying to select an object in the diagram.

In Diagram class it states that you do this by adding an item to its "SelectedObjects" collection, passing the ObjectID as a name (don't understand that)  and assume that the ObjectID is in fact DiagramObject InstanceID, but can't find a suitable method listed to perform this operation.  The collections AddNew method expects 2 strings (Name, Type)!  Not sure how I should interpret / translate this AddNew("ObjectID",InstanceIDasString)?


I've clearly missed something - anybody point me in the right direction.
Thanks


EXploringEA - information, utilities and addins

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Syntax for selecting a diagram object
« Reply #1 on: September 12, 2013, 07:28:44 pm »
I think you should do something like

Code: [Select]
myDiagram.SelectedObjects.AddNew(myElement.ElementID.ToString(),"");
Geert

EXploringEA

  • EA User
  • **
  • Posts: 172
  • Karma: +8/-0
    • View Profile
Re: Syntax for selecting a diagram object
« Reply #2 on: September 12, 2013, 07:49:07 pm »
Hi Geert

Thanks for the prompt response - that did work - now I've seen it I can see what their sparse description in the help file means;-)

Now the challenge is to force the UI to focus on the selected item so it will show the properties / tagged values window; somehow I think that API is missing!

Best regards
EXploringEA - information, utilities and addins

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Syntax for selecting a diagram object
« Reply #3 on: September 12, 2013, 07:53:24 pm »
You might need to select it in the project browser to have that effect.

Geert

EXploringEA

  • EA User
  • **
  • Posts: 172
  • Karma: +8/-0
    • View Profile
Re: Syntax for selecting a diagram object
« Reply #4 on: September 12, 2013, 08:03:12 pm »
is it possible to do that programmatically? I can't see any other selected objects collections.  Is there an API to do that or am I dreaming?
EXploringEA - information, utilities and addins

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Syntax for selecting a diagram object
« Reply #5 on: September 12, 2013, 08:46:59 pm »
You can only select one element in the project browser at a time.
See Repository.ShowInProjectView()

Geert

EXploringEA

  • EA User
  • **
  • Posts: 172
  • Karma: +8/-0
    • View Profile
Re: Syntax for selecting a diagram object
« Reply #6 on: September 12, 2013, 09:20:53 pm »
Geert

Thanks a lot - forgotten about that method - my brain must be elsewhere.
And is the final piece in the jigsaw for my current workaround - the tagged values are updated as well as the diagram element remaining selected.

Best regards
EXploringEA - information, utilities and addins