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

SclGetAttributeIndex

Overview

This command is very closely related to the SclGetValueByIndex command. In fact this command MUST be used if the SclGetValueByIndex is to be used.

Some Scl objects have one or more parameters whose values can be obtained, and in some cases set to satisfy the needs of the Scl programmer. A list of the Scl objects that this command can be applied to obtain values for attributes of interest can be found here

SclGetValueByIndex uses an integer index to determine the attribute whose value is to be returned. A value for this index must first be obtained using SclGetAttributeIndex.

Synopsis

$ObjectHandle SclGetAttributeIndex $AttributeName

Description

Return the index of the requested attribute, AttributeName, for the specified Scl object.

Arguments

  • ObjectHandle
  • The ObjectHandle variable must contain a handle to an Scl object to which the SclGetAttributeIndex command can be applied. Permitted Scl object types for the SclGetAttributeIndex command are:

    • Swa objects
      • Point
      • Segment
      • String
      • Triangle
      • Trisolation
      • Triobject
      • Swa
    • Database objects
      • Insert
      • InsertUpdate
      • Query
      • Update

  • AttributeName
  • Passed by Value. The name of the attribute for which the index value is required. A summary of the attribute names that can be used for the different Scl object types can be found here.

Returns

The integer index value for the attribute of interest for the specified scl object is returned as the result of the function.

Examples

#
# This example selects a point and then displays all X,Y and Z values for
# the segment containing the point using SclGetValueByIndex after obtaining
# the index values using SclGetAttributeIndex prior to executing the for loop
#
set status [ SclSelectPoint PointHandle "Select a point" layer string_id segment_no point_no digx digy \
digz description ]
set xindex [$PointHandle SclGetAttributeIndex x]
set yindex [$PointHandle SclGetAttributeIndex y]
set zindex [$PointHandle SclGetAttributeIndex z]
while {$status == $SCL_OK} 
{
$PointHandle SclGetParent SegmentHandle 
$SegmentHandle SclGetParent StringHandle
set count [$SegmentHandle SclCountItems]
puts "String = [$StringHandle SclGetId], Segment = [$SegmentHandle SclGetId]"
puts "X, Y, Z"
for { set i 0} {$i < $count} { incr i } 
	{
	$SegmentHandle	SclGetItem PointHandle $i puts "[$PointHandle SclGetValueByIndex $xindex], \
	[$PointHandle $yindex], [$PointHandle $zindex]"	
	}
	set status [SclSelectPoint "Select a point" layer string_id segment_no point_no digx digy \
	digz description ]
	}