Query Control Demonstration Scripts

Example #1

This following example script requires that you first load a model:
# Get Active model handle
hwi GetActiveModelHandle cl
cl GetModelHandle m [cl GetActiveModel]

# Create an element selection set and add element 100,
# then add adjacent
m GetSelectionSetHandle eset [m AddSelectionSet element]
eset Add "id == 100"
eset Add adjacent

# Get a query control, set the selection set, then define
# the query.  The query consists of a dot notation containing
# DATASOURCE.FIELD.  Data sources can be listed by calling
# GetDataSourceList, properties for a particular data source
# can be listed by calling GetDataSourceFieldList and passing
# the data source to list fields for:
#     qc GetDataSourceList returns "node element component ..."
#     qc GetDataSourceFieldList element returns "id config compid ..."

m GetQueryCtrlHandle qc
qc SetSelectionSet [eset GetID]
qc SetQuery "element.id element.connectivity"

# once the query has been set and the selection set has been assigned
# to the query control, the data can be extracted by retrieving an iterator
# and cycling through all the items in the set and calling GetDataList.
qc GetIteratorHandle qciter

for {qciter First} {[qciter Valid]} {qciter Next} {
    puts [qciter GetDataList]
}

# Release all handles
qciter ReleaseHandle
qc ReleaseHandle
eset ReleaseHandle
m ReleaseHandle

Example #2

The following example script will print the raw data of a displacement data type for all nodes:
hwi OpenStack

hwi GetActiveClientHandle cl
variable t [expr rand()];
cl GetActiveModelHandle m$t [cl GetActiveModel]

m$t GetSelectionSetHandle s$t [m$t AddSelectionSet node]
s$t Add all

m$t GetQueryCtrlHandle q$t
q$t SetSelectionSet [s$t GetID]

q$t SetDataSourceProperty result datatype Displacement;

q$t SetQuery "node.id result.value"


q$t GetIteratorHandle i$t;

for { i$t First }  { [i$t Valid] } { i$t Next } {
    puts "data is  [i$t GetDataList]"

} 
hwi CloseStack