SclBlockModelGetValues
Overview
You use this command to get the values of attributes of blocks in a block model. You must identify each block by referring to its block index number.
Prerequisites:You need a handle to the block model of interest. See SclBlockModelGetCurrentModel for more information on block model handles.
Syntax
SclBlockModelGetValues $bmHandle $blockIndex $attributeNames attributeValues
Description
You must specify a valid block index number for this command. You can get the block index number using a call to SclBlockModelIterateNext, or SclBlockModelColumnIterateStart, or SclBlockModelLevelIterateStart.
Arguments
| Argument | Description |
|---|---|
| bmHandle | Passed by value. This is the handle to the block model obtained from the call to SclBlockModelGetCurrentModel. |
| blockIndex | Passed by value. This is the index number of the block for which the attribute values are required. You can use SclBlockModelBlockIndexFromXYZ to get the block index number. |
| attributeNames | Passed by value. This is the list of attribute names for which the values are required. If any of the specified attributes do not exist in the block model, an error is returned and the script stops. |
| attributeValues | Passed by reference. The attributeValues variable is treated as a TCL list. The attribute values for the block are stored in the list. Any values already in the list are removed from the list before the values are appended. |
Returns
If the command is successful, $SCL_OK is returned. If an error occurs, $SCL_FALSE is returned.
Example
#You can use this code sample, as it is, with the tutorials\block_modelling\training.mdl block model.
#For other block models, you may need to change: attributes to get, coordinates, or userBlockSubLevel
#Get the block model handle
set bmHandle [SclBlockModelGetCurrentModel]
#Set the list of attributes whose values are required.
#You can get attributes of any type including text, integer, and calculated attributes.
set attribsToGet {"gold" "sg"}
#Set the coordinates of the blocks for which we need the attributes' values
set coordinates {{"1482" "7195" "897.5"} {"1440" "7080" "740"}}
#Set the user block level
set userBlockSubLevel 7
#Iterate through each coordinate
foreach {coordinate} $coordinates {
foreach {x y z } $coordinate {
#Get the block index from the x,y,z coordinates
set idx [SclBlockModelBlockIndexFromXYZ $bmHandle $userBlockSubLevel $x $y $z blockStatus]
if {$blockStatus == 0} {
#Get the attributes' values at this index
SclBlockModelGetValues $bmHandle $idx $attribsToGet attribValues
#Display the attribute values
for {set i 0} {$i < [llength $attribValues]} {incr i} {
puts -nonewline "[lindex $attribsToGet $i] : "
puts -nonewline "[lindex $attribValues $i] "
}
puts ""
}
}
}
|