Navigation: Scripting Reference Manual > Functions & Subroutines > GetSibling

 

GetSibling

 

Contact Us: fredsupport@photonengr.com

 

Description

This function returns the node number of the first sibling to the specified entity.  If the specified entity does not have a sibling, then the function returns a -1.

 

Syntax

siblingNode = GetSibling ( nEnt )

 

Parameters

siblingNode (Long)

Returned node number of the first sibling of nEnt.  This will be a -1 if nEnt has no sibling.

 

nEnt As Long

Node number of the entity being queried for its sibling.

 

Example

The example below demonstrates a recursive function that makes use of GetChild and GetSibling to recurse down the object tree hierarchy from a specific node by a specific number of levels and operate on each descendant with some custom code.

 

Dim nodeLevel As Long

 

Sub Main

 

  ClearOutputWindow()

  Print "Entity" & vbTab & "Level"

  Dim startNode As Long

  startNode = 2

  nodeLevel = 0

  ResetTraceable startNode, True

 

End Sub

 

Sub ResetTraceable( ByVal nodeID As Long, _

                    ByVal recurse As Boolean)

 

    Dim idx As Long

    If nodeID < 0 Then Exit Sub

        If IsSurface( nodeID ) Then

            Print GetFullName(nodeID) & vbTab & nodeLevel

            '... do something here ...

        End If

    If recurse Then

        idx       = GetChild( nodeID )

        nodeLevel = nodeLevel + 1

        While idx > 0

            ResetTraceable( idx, recurse )

            idx = GetSibling( idx )

        Wend

    End If

    nodeLevel = nodeLevel - 1

 

End Sub

 

 

See Also

FindFullName

GetEntity

GetChild

GetParent

GetType

 

 

 

 

 

 

Copyright © Photon Engineering, LLC