GiD - The personal pre and post processor

Access to tree data information

This document shows an example about the access to the data stored in the customlib tree. We are using the cmas2d_customlib tree as example.
The customlib tree is stored in a xml document. To manage an xml object, we use the tdom functions, available in https://docs.activestate.com/activetcl/8.6/tcl/tdom


Tree example
To get the value of the weight applied to the group Point Weight Auto1, we need to define the xpath to the value, and ask it to the document.

set document [$::gid_groups_conds::doc documentElement]
set xpath {/cmas2d_customlib_data/condition[@n='Point_Weight']/group[@n='Point Weight Auto1']/value[@n='Weight']}
set xml_node [$document selectNodes $xpath]
set value [get_domnode_attribute $xml_node v]


To get all the groups assigned to that condition:

set document [$::gid_groups_conds::doc documentElement]
set xpath  {/cmas2d_customlib_data/condition[@n='Point_Weight']/group}
set group_ids []
foreach group_node [$document selectNodes $xpath] {
    set group_id [get_domnode_attribute $group_node n]
    lappend group_ids $group_id
}


Note: To see the whole xml document, execute

W [[$::gid_groups_conds::doc documentElement] asXML]



COPYRIGHT © 2022 · GID · CIMNE