Extraction of elements id number

Moderator: GiD Team

Post Reply
mzed
Posts: 2
Joined: Thu Nov 09, 2017 3:54 pm

Extraction of elements id number

Post by mzed »

Hello,
I'm trying to write a TCL script that returns the ID number of elements inside a condition. Right now I'm using:

Code: Select all

set points [GiD_Info conditions Corner geometry]
which returns something like this:
points = {E 3 -} {E 4 -}

Is it possible to return the ID only, without the need to mess with regular expressions to retrieve this information?
User avatar
escolano
Posts: 1918
Joined: Sun Sep 05, 1982 10:51 pm

Re: Extraction of elements id number

Post by escolano »

The result is returned formatted as a Tcl list for computers not for humans.
You don't need to apply any expensive regular expression to match parts !!

The result is a list of items (the condition is applied to more than an entity)
and each item is also a list with
letter_code entity_id - value1 ... valuen

letter_code allow know the type of entity
entity_id is the entity id that do you want to know
- is a separator that doen't has any meaning
value1 to value2 are the values of the questions defined for the condition

letter_code it is
E for all geometric items
N for node
E for element
the 'element faces' is an special case, because there is formed by two ids: the element id and the local face id (from 1 to num faces of the element)
in this case the letter_code store the element_id and the entity_id store the local face id

Concluding, in your case
set points [GiD_Info conditions Corner geometry]
-> points = {E 3 -} {E 4 -}
could get a list of the point id with something like this

Code: Select all

set point_ids [list]
foreach item [GiD_Info conditions Corner geometry] {
  lappend point_ids [lindex $item 1]
  # set question_values [lrange $item 3 end]
}
In your case there are not any question value, I have added a commented line that suggest how to get them if necessary
mzed
Posts: 2
Joined: Thu Nov 09, 2017 3:54 pm

Re: Extraction of elements id number

Post by mzed »

Thanks for the quick reply,
I already knew the syntax of each item, but my case is somewhat particular since i'm dealing with a combination of EM and optimization problem. The condition I'm looking for is just a flag to identify elements which will later be assigned another condition. The idea is to define a set of points with a single condition (hence I did not set a value), then looping over each point in that condition and assign an incremental value in another condition (through GiD_AssignData).
Another possibility is to isolate points by means of layers, I'm figuring out which is the best way. Any suggestion regarding this?

Thanks
Marcello
User avatar
escolano
Posts: 1918
Joined: Sun Sep 05, 1982 10:51 pm

Re: Extraction of elements id number

Post by escolano »

You can also use groups, it is similar to layers but is possible that an entity belong to more than a group (but only can belong to a layer)

layers are useful to create/edit a model, setting on/off some parts
groups are useful to define regions to attach after some properties (boundary conditions) for the calculation

Both layer and groups data doesn't depend on a problemtype, can be used without load any problemtype and survive to the unload of the problemtype
conditions on the other hand are defined by each problemtype, and its data cannot be used to calculate with other problemtype
Post Reply