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

SclBlockModelIterateNext

Overview

You use this command to advance a specified block model iterator to the next block in the model, constraint, or column, depending on the type of the iterator and whether a constraint is being used. The attributes you specify for the block are then retrieved into memory.

Synopsis

SclBlockModelIterateNext $iterator attributeValues blockStatus

Description

This command retrieves the values for the set of attributes for the specified iterator, and adds them to the attributeValues parameter. The iterator then advances to the next block.

Arguments

  • iterator
  • Pass by value. This is the handle to the iterator. See SclBlockModelIterateStart. If the specified iterator is invalid, an error is returned and the script terminates.

  • attributeValues
  • Pass by reference. The variable specified here is treated as a TCL list. The attribute values for the current block are stored in the list. Any values already in the list are removed from the list before the values are appended.

  • blockStatus
  • Pass by reference (optional). This variable is assigned the status of the block that the iterator is pointing to. A status of -1 is a white block, 0 is a black block, and 1 is a grey block.

Returns

If this command is successful, it returns a value representing the index of the block that the iterator currently points to. If the iterator has reached the end of the block model, it returns a value of -1.

Note: If an iterator reaches the end of the block model, and SclBlockModelIterateNext is called again, the iterator is moved to the first block.

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