TCL Script - Loops and Object-IDs

Inhalt

Index

A list of AllplanBridge objects is defined by the first object, the last object and the number of objects. The IDs are temporary. To iterate the objects in a for-loop, you need the following commands:

Commands OBJNEXT and OBJPREV

Call

Argument

Meaning

[OBJNEXT id]

OBJID

The ID of the successor of the object with the ID id is returned. If id = 0 or id represents the last object in the list, then 0 will be returned.

[OBJPREV id]

OBJID

The ID of the predecessor of the object with the ID id is returned. If id = 0 or id represents the first object in the list, then 0 will be returned.

TCL-arrays as return values of commands

If the array items are not known, they can be queried (see example). Since the AllplanBridge objects will also be extended in the future, new array items can be added later. But the present ones stays valid.

Example of a loop over all axes

array set axes [ABMAXES GET LIST]

if { $axes(count) > 0 } {

set ID $axes(first)

for { set iaxis 0 } { $iaxis < $axes(count) } { incr iaxis } {

if { $iaxis > 0 } { set ID [OBJNEXT $ID] }

ABMINFO " Axis ID:" $ID

# reset array-variable axis

array unset axis

array set axis [ABMAXIS $ID GET]

ABMINFO " Axis " $axis(name) ":"

ABMINFO " ---------------------"

# output of all array items

foreach {key value} [array get axis] {

ABMINFO " " $key " = " $value

}

}

}

The information of all existing axes is output in the log area.



Allplan

(C) ALLPLAN GmbH

Privacy policy