Book a Demo

Author Topic: Get DiagramObject objects  (Read 4496 times)

SvenK

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Get DiagramObject objects
« on: May 02, 2013, 07:13:00 pm »
Hello,

I want to set the style of all components in all diagrams automatically using jscript. I created an SQL search and have the Object_IDs of the desired DiagramObjects. However, I couldn't find a function to get the DiagramObject using the ID (something similar to Reposityor.GetElementByID (long ElementID) ).

Do I really have to iterate over each Diagram there iterate over Diagram.DiagramObjects?

Sven

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Get DiagramObject objects
« Reply #1 on: May 02, 2013, 08:39:45 pm »
Sven,

A diagramObject contains a DiagramID.
So the best you can do is use Repository.SQLQuery() to get the diagramID's, get the diagrams using Repository.GetDiagramByID() , and then iterate the Diagram.DiagramObjects to find the ones you need.

Geert

Paulus

  • EA User
  • **
  • Posts: 152
  • Karma: +0/-0
    • View Profile
Re: Get DiagramObject objects
« Reply #2 on: May 02, 2013, 09:07:48 pm »
I don't know of a way to do this using the EA api but since you say you want to update -all- components on -all- diagrams using the EA API may turn out to be too slow at any rate.

It would be much faster to directly update the column ObjectStyle in the  t_diagramobjects table and then reload any open diagrams by calling Repository.RefreshOpenDiagrams to reflect the changes.


Btw note that the object_id is not the identifier of the diagram object but of the element behind the diagramobject... and an element may appear multiple times in different diagrams.

best regards,

Paulus
« Last Edit: May 02, 2013, 09:10:35 pm by pmaessen »

atallec

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Get DiagramObject objects
« Reply #3 on: May 16, 2013, 07:07:37 pm »
Hi Sven,

This request should work fine.

select D.name, D.diagram_id, O.name, O.object_id
from t_object O, t_diagram D, t_diagramobjects OD
where OD.object_id=O.object_id and OD.diagram_id=D.diagram_id
order by D.name, O.name

Alexandre Tallec