You are here: Surpac Concepts > Macros > SCL > Block Model Commands > SclBlockModelLevelIterateStart
GEOVIA Surpac

SclBlockModelLevelIterateStart

Overview

You can use this command to get a level iterator which points to a specified block model, at a specified subdivision level, in Surpac. If a block does not include any sub-blocks, you can use the level iterator to retrieve values for block attributes.

Synopsis

SclBlockModelLevelIterateStart $bmHandle $level $attributeNames "constraintfile=$constraintFile"

SclBlockModelLevelIterateStart $bmHandle $level $attributeNames "constrainthandle=$constraintHandle"

Description

You need a handle to the block model of interest. See SclBlockModelGetCurrentModel for more information on block model handles. The parameters $attributesNames, "constraintfile=$constraintFile", and "constrainthandle=$constraintHandle" are optional. However, if you specify a constraint file or constraint handle, you must also specify the attribute name parameter.

Arguments

  • bmHandle
  • Passed by value. This is the handle to the block model, obtained from the call to SclBlockModelGetCurrentModel.

  • level
  • Passed by value. This is the block subdivision level. This must be more than 0 and less than the maximum subdivision level for the block model.

  • attributeNames
  • Passed by value (optional). A list of attribute names corresponding to the attributes that exist in the block model. If any of these attributes do not exist, an error is returned and the script stops. If this parameter is not specified, every attribute within the block model is used including the intrinsic geometry attributes _xorg, _yorg, _zorg, _xcen, _ycen, _zcen, _xext, _yext, _zext, _xindex, _yindex, _zindex.

  • "constraintfile=$constraintFile"
  • Passed by value (optional). You can use this parameter only if the attributeNames parameter is present. This parameter specifies the name, including the path if necessary, to a constraint file to use when iterating over blocks in the block model. If the constraint file does not exist, or it is invalid for the specified block model, an error is returned and the script is stopped.

  • "constrainthandle=$constraintHandle"
  • Passed by value (optional). You can use this parameter only if the attributeNames parameter is present. This parameter specifies the name, including the path if necessary, to a constraint handle to use when iterating over blocks in the block model. If the constraint handle does not exist, or it is invalid for the specified block model, an error is returned and the script is stopped. To create a constraint handle, see SclBlockModelCreateConstraint.

Returns

If the command is successful, it returns a value that represents the level iterator, which is required by some other commands such as SclBlockModelIterateNext and SclBlockModelIterateEnd. If an error occurs, $SCL_FALSE is returned.

Examples

# Create a level iterator for a specified block model which uses a specific set of attributes and a
# constraint file. This iterator will use a sub-division level value of 6 and iterate over all the blocks in
# the constraint, outputting the values of the attributes for each.

set bm [SclBlockModelGetCurrentModel]

# Example attribute names
set attributeList {"att1" "att2" "att3"}

# Example constraint file name
set constraintFileName "c:\\constraintfile.con"

set level 6
set iterator [SclBlockModelLevelIterateStart $bm $level $attributeList "constraintfile=$constraintFileName"]
set result [SclBlockModelIterateNext $iterator attributeValues]
while {$result != -1} {
  foreach value $attributeValues {
    puts -nonewline "$value, "
  }
  puts ""
  set result [SclBlockModelIterateNext $iterator attributeValues]
}
SclBlockModelIterateEnd $iterator

					

 

# Create a level iterator for a specified block model which uses a specific set of attributes and a
# constraint handle. This iterator will use a sub-division level value of 6 and iterate over all the blocks
# in the constraint, outputting the values of the attributes for each.

set bm [SclBlockModelGetCurrentModel]

# Set attribute names
set attributeList {"att1" "att2" "att3"}

# Create a constraint handle
set constraintHandle [SclBlockModelCreateConstraint $bm]

# Add a block which is at the location x, y, z to the constraint handle
set x 1800
set y 7600
set z 100
set level 6

set blockIndex [SclBlockModelBlockIndexFromXYZ $bm $level $x $y $z  blockStatus]
SclBlockModelAddBlockToConstraint $constraintHandle $blockIndex 

set iterator [SclBlockModelLevelIterateStart $bm $level $attributeList "constrainthandle=$constraintHandle"]
set result [SclBlockModelIterateNext $iterator attributeValues]
while {$result != -1} {
  foreach value $attributeValues {
    puts -nonewline "$value, "
  }
  puts ""
  set result [SclBlockModelIterateNext $iterator attributeValues]
}
SclBlockModelIterateEnd $iterator
SclBlockModelDestroyConstraint $constraintHandle

					

 

# Create an iterator for a specified block model which uses a specific set of attributes and a constraint file.  
# Iterate over all blocks in the model, outputting the values for the attributes to the message window. 
# A block model must already be loaded for this to work.
set bm [SclBlockModelGetCurrentModel]

# Example attribute names
set attributeList {"att1" "att2" "att3"} 

# Example constraint file name
set constraintFileName "c:\\constraintfile.con"

set iterator [SclBlockModelIterateStart $bm $attributeList "constraintfile=$constraintFileName"]
set result [SclBlockModelIterateNext $iterator attributeValues]
while {$result != -1} {
  foreach value $attributeValues {
   puts -nonewline "$value, "
  }
  puts ""
  set result [SclBlockModelIterateNext $iterator attributeValues]
}
SclBlockModelIterateEnd $iterator