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

SclBlockModelIterateStart

Overview

You can use this command to get an iterator that points to a specified block model in Surpac. You can use the iterator to retrieve values for block attributes.

Synopsis

SclBlockModelIterateStart $bmHandle $attributeNames "constraintFile=$constraintFileName"

SclBlockModelIterateStart $bmHandle $attributeNames "constraintHandle=$constraintHandle"

SclBlockModelIterateStart $bmHandle $attributeNames

SclBlockModelIterateStart $bmHandle

Description

You need a handle to the block model of interest. See SclBlockModelGetCurrentModel for more information on block model handles. The parameters attributeNames and constraintFileName are optional. However, if you specify a constraint file, you must also specify the attributeNames parameter.

Arguments

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

  • 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=$constraintFileName
  • Passed by value (optional). You can use this parameter only if the attributeNames parameter is present. This parameter specifies the path 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 stops.

  • constraintHandle=$constraintHandle
  • Passed by value (optional). You can use this parameter only if the attributeNames parameter is present. This parameter specifies the constraint handle, for a constraint file loaded in memory, 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 stops.

Returns

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

Examples

#Create an iterator for a specified block model which uses all attributes and no 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]
set iterator [SclBlockModelIterateStart $bm]
set result [SclBlockModelIterateNext $iterator attributeValues]
while {$result != -1} {
	foreach value $attributeValues {
	puts -nonewline "$value, "
	}
	puts ""
	set result [SclBlockModelIterateNext $iterator attributeValues]
}
SclBlockModelIterateEnd $iterator
					

 

#Create an iterator for a specified block model which uses a specific set of attributes and no 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"}

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

 

#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