This example shows how to traverse through all the objects in the project, using the IInformationTree5 interface, find all the text labels and set their altitude to 10 meters above ground.
<HTML>
<b>Traverse Tree sample</b></br>
This sample shows how to traverse the information tree and set all the labels' heights to 10 meters above ground</br></br>
<SCRIPT Language="VBSCRIPT">
Dim IInfoTree
Dim IObjectManager51
sub SetLabelsHeights()
Set IInfoTree = TE.interface("IInformationTree5")
Set IObjectManager51 = TE.interface("IObjectManager51")
'Start with the Information Tree root (0)
TraverseBranch 0
end sub
sub TraverseBranch(ItemID)
'Get the first child item of this group.
SiblingItemID = IInfoTree.GetNextItem(ItemID, 11)
If SiblingItemID = 0 Then
Exit Sub
End if
'Start with the first child item and traverse
'all of the sibling items in that group.
While SiblingItemID <> 0
If IInfoTree.IsGroup(SiblingItemID) Then
'If we are here, this tree item is a group.
'A recursive call - traverse all of the tree items under this group.
TraverseBranch SiblingItemID
Else
'If we are here, this tree item is an object.
'Get an interface to the object that this is its ID.
On Error Resume Next
Set ITerraExplorerObject5 = IinfoTree.GetObjectEx(SiblingItemID, “”)
If not ITerraExplorerObject5 is nothing Then
On Error Resume Next
'Check to see the type of this object is (18 is a label).
'See TerraExplorerObject::ObjectType documentation for a detailed list of
'possible values.
If ITerraExplorerObject5.ObjectType = 18 Then
'Set the label height to 10 meters (the last parameter is a combination of the
'following values: IGNORE_X | IGNORE_Y | IGNORE_ORIENTATION.
'See ITerrainLocation5::SetPosition method for a detailed list of possible values).
ITerraExplorerObject5.SetPosition 0,0,10,0,0,0,61
End If
End If
End If
'Continue to the next sibling tree item.
SiblingItemID = IInfoTree.GetNextItem(SiblingItemID, 13)
Wend
end sub
</SCRIPT>
<INPUT type=button value="Set Labels' Heights" name="Set Labels' Heights" onclick="SetLabelsHeights()"></br>
<BODY>
<OBJECT ID="TE" CLASSID="CLSID:3a4f9191-65a8-11d5-85c1-0001023952c1"></OBJECT>
</BODY>
</HTML>