NavigateNode

導入

v1.5

詳細

ナビゲーション フィルタやディレクションが与えられている指定のオブジェクト/コンポーネントの中をナビゲートします。 対応するオブジェクトまたはコンポーネントを戻します。

注: エレメントを選択する場合は、このコマンドではなく SelectNeighborObj を使用します。

スクリプト構文

oReturn = NavigateNode( [Source], [NavDirection], [NavLoop], [NavFilter], [NavSubFilter], [OutputObj] );

戻り値

要求された位置に存在するノード。または、ノードが存在しない場合は InputObj。

注: 条件に合致した最初のノードのみが戻されます。

パラメータ

パラメータ タイプ 説明
Source 選択リスト ナビゲーションの開始ポイント

デフォルト値: 現在選択されている値

NavDirection Integer ナビゲート方法を指定します( 親や子の階層、シブリング階層などに移動します)。

デフォルト値: siParentNode

指定可能な値:

説明:

siParentNode 親を取得
siChildNode 子を取得
siNextNode 次のシブリングを取得
siPreviousNode 前のシブリングを取得
siFirstNode 最初のシブリングを取得
siLastNode 最後のシブリングを取得
NavLoop Boolean 終了位置に到達したときや最後まで検索し終わったときに、階層の開始位置に戻るか、検索を継続するかを指定します。

デフォルト値: False

指定可能な値:

説明:

False 階層全体をループしません。
True 階層全体をループします。
NavFilter Integer 戻したいオブジェクトの種類。 NavDirection が siParentNode または siChildNode である場合は、この値とは無関係に必ずデフォルトのフィルタリングが使用されます。

デフォルト値:11:入力と同じタイプ

指定可能な値:

説明:

1 Scene
2 3D オブジェクト
3 オペレータ
4 Primitive
5 コンテナまたは属性
6 Cluster
7 サブコンポーネント
8 Group
9 任意の COM オブジェクト
10 任意の型
11 入力と同じタイプ
NavSubFilter Integer 目的のオブジェクトの SubType。 NavFilter 引数と併用します。

デフォルト値: 1: 入力と同じタイプ

指定可能な値:

説明:

0 任意の型
1 入力と同じタイプ
OutputObj SIObject (たとえば、ParameterProperty、または X3DObject)から導かれたオブジェクト 要求された位置に存在するノード。 ノードが存在しない場合は、InputObj パラメータにより指定されているノードが戻されます。

注: 条件に合致した最初のノードのみが戻されます。

1. VBScript の例

' Returns the children of the current selection in a collection

' Ouput: XSICollection	| Children of the selected object

Function GetChildren()

	Set childColl = CreateObject( "XSI.Collection" )

	If Selection.Count <> 1 Then

		MsgBox "You must select an object in order to get its children.", vbExclamation, "GetChildren"

	Else

		Set oSelected = Selection(0)

		SetUserPref "SCR_CMDLOG_ENABLED", False

		' get the first child

		Set oChild = NavigateNode( oSelected, siChildNode )

		Set oCurrent = oChild

		' if there is at least one child

		If	StrComp( oSelected, oChild ) <> 0 Then

			' Add the child and its siblings to the collection

			Do 

				childColl.Add oCurrent

				set oCurrent = NavigateNode( oCurrent, siNextNode, True, 10 )

			Loop Until StrComp( oCurrent, oChild ) = 0

		End If

		SetUserPref "SCR_CMDLOG_ENABLED", True

	End If

	Set GetChildren = childColl

End Function

' Displays the content of a collection in the scripting

' log

' Input: oColl	| Collection to display

Sub DisplayCollectionContent( ByRef oColl )

	Dim message

	message = "The collection contains the following elements:" & vbLF & vbLF

	For Each element In oColl

		message = message & element & vbLf

	Next

	LogMessage message

End Sub

' Create a new scene with a null then display its children

NewScene ,False

GetPrim "Null", "MyNull"

DisplayCollectionContent( GetChildren() )

'Output of the above script:

'INFO : "The collection contains the following elements:

' 

' MyNull.Name

' MyNull.null

' MyNull.AmbientLighting

' MyNull.Scene_Material

' MyNull.geomapprox

' MyNull.display

' MyNull.kine

' MyNull.visibility

' MyNull.kine

' MyNull.display

' MyNull.visibility

' MyNull.Children

'"

2. VBScript の例

' Create a sphere and a cone :

oSphere = CreatePrim( "Sphere", "MeshSurface" )

oCone = CreatePrim( "Cone", "MeshSurface" )

ParentObj oSphere, oCone 

'

' Navigate in the 3D object hierarchy.

'

LogMessage " --- Object Navigation ---"

' First, from the sphere, navigate "up" to get the scene root:

rtn = NavigateNode( oSphere, 1, , , 0 )

LogMessage "From " & oSphere & ", we obtained " & rtn 

' Now navigate "down" from the sphere:

rtn = NavigateNode( oSphere, 2, , 11, 0 )

LogMessage "From " & oSphere & ", we obtained " & rtn 

'

' Now, navigate amongst newly created clusters.

'

LogMessage "--- Cluster Navigation ---"

oCls1 = CreateCluster( oSphere & ".pnt[25-27,31-34,38-41]" )

oCls2 = CreateCluster( oSphere & ".pnt[3-6,11-13,52-55]" )

' From the first cluster, get the second one:

rtn = NavigateNode( oCls1, 3, True )

LogMessage "From " & oCls1 & ", we obtained " & rtn 

' From the previously obtained cluster, return the next one.

' If the next one doesn't exist, make sure we loop.

LogMessage "We have now reached the end of the cluster list."

newrtn = NavigateNode( rtn, 3, True, 6, 1 )

LogMessage "From " & rtn & ", we loop and we obtained " & newrtn 

' Same as above but this time, we will not "loop".

newrtn = NavigateNode( rtn, 3, False, 6, 1 )

LogMessage "From " & rtn & ", we DON'T loop and we obtained " & newrtn 

' Running this script should log the following:

' ---------------------------------------------

'INFO : " --- Object Navigation ---"

'INFO : "From sphere, we obtained Scene_Root"

'INFO : "From sphere, we obtained sphere.Name"

'INFO : "--- Cluster Navigation ---"

'INFO : "From sphere.polymsh.cls.Point, we obtained sphere.polymsh.cls.Point1"

'INFO : "We have now reached the end of the cluster list."

'INFO : "From sphere.polymsh.cls.Point1, we loop and we obtained sphere.polymsh.cls.Point"

'INFO : "From sphere.polymsh.cls.Point1, we DON'T loop and we obtained sphere.polymsh.cls.Point1"

関連項目

SelectNeighborObj