Author Topic: Get alle Elements  (Read 4592 times)

Ceronimo

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Get alle Elements
« on: April 15, 2016, 08:10:45 pm »
Hi
at firs    i gave some elements ataggedvalue "isRegistred".

Now i want to see after an Event which Elements have this tag !

I know how to get a tag of the element,

but i don`t know how to get all Elements

and in a Routine then i want to check all elements if they have These tagged value.

1. How can i save all Elements in the open Project in EA.Element[] Array ??
2. The id of aRoot i only can get with parentid not with package id  , i have wrote a recursive Routine,
which should find the Root but i always get a Message id not found, if i hardcode it i only can get it with parentid ?
« Last Edit: April 15, 2016, 08:19:05 pm by Ceronimo »

Ceronimo

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Get alle Elements
« Reply #1 on: April 15, 2016, 08:15:18 pm »
Note:

I already tried to get the Elements with

EA.Collection aCollection=getElementSets(null,0);

EA.Element aElement=aCollection.getat(x);

but it doesnt work !

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Get alle Elements
« Reply #2 on: April 15, 2016, 11:44:27 pm »
You don't want to go and check each element in your model, that will take forever.

Better be clever and only get those that have that specific tagged value.

GetElementSet can also be used with an SQL query that returns the ObjectID's.

So you use it as follows

Code: [Select]
string SQLQuery = @"select o.Object_ID from (t_object o
inner join t_objectproperties tv on tv.Object_ID = o.Object_ID)
where tv.Property = 'isRegistered'";
EA.Collection allRegisteredElements = Repository.GetElementSet(SQLQuery, 2);

Geert

Ceronimo

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Get alle Elements
« Reply #3 on: April 18, 2016, 11:17:08 pm »
thank you geert it worked again, like always

 ;D ;D ;D ;D