You are here: Surpac Concepts > Macros > SCL > Object Manipulation > SclGetItem
GEOVIA Surpac

SclGetItem

Overview

The SclGetItem command operations on any object that represents a container (or set) of child objects and returns a member of that set of objects and assigns its handle to an Scl object handle variable. SclGetItem is commonly used with the SclCountItems command and the Tcl for command.

Synopsis

$ParentHandle SclGetItem ChildHandle $Position

Description

Return into the ChildHandle variable the child object at position $Position in the set of objects defined by $ParentHandle.

Arguments

  • ParentHandle
  • The Scl object handle variable to the set of child objects from which an item is required.

  • ChildHandle
  • Passed by reference. The variable to which the handle of the child object is required.

  • Position
  • Passed by value. The position in the set at which the item of interest exists. The position for the first item when getting triangles in the set of triangles for a trisolation and trisolations in the set of trisolations for a triobject is 1. In all other cases the position for the first item in the set of interest is 0.

Examples

#
# This example shows how a count of the number of SWAs in the set of 
# Graphics layers can be obtained and also how a SWA at a specified 
# position in the set of Graphics layers be obtained and assigned to a 
# variable
#
set count [sclGraphicsLayers SclCountItems]
puts "There are $count Swas in the set of Graphics Layers"
for {set i 0} {$i < $count} {incr i} {
  sclGraphicsLayers SclGetItem SwaHandle $i
  puts "The Graphics Layer at position $i is [$SwaHandle SclGetId]"
}

 

#
# This example shows how a count of the number of strings in the SWA
# can be obtained and also how a string at a specified position in the
# SWA can be obtained and assigned to a variable
#
SclGetActiveViewport ViewportHandle
$ViewportHandle SclGetActiveLayer SwaHandle
$SwaHandle SclGetStrings StringsHandle
set count [$StringsHandle SclCountItems]
puts "There are $count strings in the Swa"
for {set i 0} {$i < $count} {incr i} {
  $StringsHandle SclGetItem StringHandle $i
  puts "The string at position $i is [$StringHandle SclGetId]"
}