v9.0 (2011)--see X3DObject.FindChildren2
Finds all X3DObject children of an
X3DObject object that match a set of
search criteria. By default the search is done recursively. The
function returns all objects satisfying the following criteria:
name, type and family(ies). This method is typically used for
hierarchically navigating a scene of 3D objects.
To get the collection of all X3DObjects children under a given X3DObject, including those nested inside all
Models and parented under X3DObjects, call this method with no
arguments. For getting all X3DObject
objects in a scene you may want to use FindObjects instead for better
performance.
oReturn = X3DObject.FindChildren( [Name], [Type], [Family], [Recursive] ); |
Parameter | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Name | String or CollectionItem | A name expression or a CollectionItem, the expression can also contain wildcard characters. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Type | String | The type of object defined by siType
or an empty string if no type is used. The type can be a specific
X3DObject type such as siModelType and si3DObjectType or a
primitive type such as siPolyMeshType or siSrfMeshPrimType. If a
primitive type is supplied, the function considers only the
children objects defined with a primitive of this type. The valid
types are listed below.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Family | siFamily or Array of siFamily elements. | An array of families defined by siFamily or an empty array if
none are required. The families are used for narrowing down the
search, the array can contain X3DObject families like
si3DObjectFamily or primitive families such as
siNurbsSurfaceMeshFamily or siNullPrimitiveFamily. Only the
children objects that match the supplied families are considered.
If primitive families are supplied then only the objects defined
with a primitive that belongs to one of them are considered. The
valid families are listed below.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Recursive | Boolean | Recurse if True, otherwise the search is done on the immediate
children. This recursion will include the contents of any X3DObjects found nested underneath the object.
Default Value: True |
NewScene , false set oRoot = Application.ActiveProject.ActiveScene.Root oRoot.AddGeometry "Sphere", "MeshSurface", "mySphere" oRoot.AddGeometry "Cone", "MeshSurface", "myCone" oRoot.AddGeometry "Cone", "MeshSurface", "anotherCone" oRoot.AddGeometry "Cube", "NurbsSurface", "myCube" Application.LogMessage "** 1: Find all objects whose names start with 'Camera' **" set kids = oRoot.FindChildren( "Camera*" ) for each pip in kids Application.LogMessage( "Found child: " & pip.Name ) next Application.LogMessage "** 2: Find all objects of type siLightPrimType **" set kids = oRoot.FindChildren( , siLightPrimType ) for each pip in kids Application.LogMessage( "Found child: " & pip.Name ) next Application.LogMessage "** 3: Find all objects that belong to siNullPrimitiveFamily and siMeshFamily families **" set kids = oRoot.FindChildren( , , Array( siNullPrimitiveFamily, siMeshFamily ) ) for each pip in kids Application.LogMessage( "Found child: " & pip.Name ) next Application.LogMessage "** 4: Find all objects whose names start with 'my' and belong to siMeshFamily family **" set kids = oRoot.FindChildren( "my*", , Array(siMeshFamily) ) for each pip in kids Application.LogMessage( "Found child: " & pip.Name ) next ' Expected results: 'INFO : ** 1: Find all objects whose names start with 'Camera' ** 'INFO : Found child: Camera_Root 'INFO : Found child: Camera 'INFO : Found child: Camera_Interest 'INFO : ** 2: Find all objects of type siLightPrimType ** 'INFO : Found child: light 'INFO : ** 3: Find all objects that belong to siNullPrimitiveFamily and siMeshFamily families ** 'INFO : Found child: Camera_Root 'INFO : Found child: Camera_Interest 'INFO : Found child: mySphere 'INFO : Found child: myCone 'INFO : Found child: anotherCone 'INFO : ** 4: Find all objects whose names start with 'my' and belong to siMeshFamily family ** 'INFO : Found child: mySphere 'INFO : Found child: myCone |
/* Compare this example with the similar example for X3DObject.Children */ // Create a sample scene NewScene( null, false ); var oNull = Application.ActiveSceneRoot.AddNull( "MyNull" ); var oSphere = Application.ActiveSceneRoot.AddGeometry( "Sphere", "MeshSurface", "MySphere" ); var oNestedSphere = oNull.AddNull( "NestedNull" ); var oConeInModel = Application.ActiveSceneRoot.AddGeometry( "Cone", "NurbsSurface", "ConeInMdl" ); var oModel = Application.ActiveSceneRoot.AddModel( oConeInModel, "MyModel" ); // FindChildren can be more powerful than X3DObject.Children because by default it will // recurse through the graph finding all nested children. PrintChildren( "FindChildren of SceneRoot:", Application.ActiveSceneRoot.FindChildren() ) ; PrintChildren( "FindChildren of Null:", oNull.FindChildren() ) ; PrintChildren( "FindChildren of Model:", oModel.FindChildren() ) ; //Expected Results: //INFO : FindChildren of SceneRoot //INFO : Camera_Root //INFO : Camera //INFO : Camera_Interest //INFO : light //INFO : MyNull //INFO : NestedNull //INFO : MySphere //INFO : MyModel //INFO : MyModel.ConeInMdl //INFO : ---------------------------- //INFO : FindChildren of Null //INFO : NestedNull //INFO : ---------------------------- //INFO : FindChildren of Model //INFO : MyModel.ConeInMdl //INFO : ---------------------------- // Helper function showing the contents of a collection function PrintChildren( in_msg, in_oChildren ) { Application.LogMessage( in_msg ); for ( var i=0 ; i<in_oChildren.Count ; i++ ) { Application.LogMessage( "\t" + in_oChildren.Item(i).FullName ); } Application.LogMessage( "----------------------------" ) ; } |