X3DObject.FindChildren

Deprecated

v9.0 (2011)--see X3DObject.FindChildren2

Description

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.

C# Syntax

X3DObjectCollection X3DObject.FindChildren( Object in_varName, String in_pbstrType, Object in_famArray, Boolean in_bRecursive );

Scripting Syntax

oReturn = X3DObject.FindChildren( [Name], [Type], [Family], [Recursive] );

Return Value

X3DObjectCollection

Parameters

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.

Possible Values:

Description:

si3DObjectType 3D Object type
siArcPrimType Implicit Arc Primitive type
siAttractorCtrlType Attractor Control Object type (electric force)
siCameraPrimType Camera Primitive type
siCameraRootPrimType Camera Root primitive type
siChainBonePrimType Chain Bone Primitive type
siChainEffPrimType Chain End Effector Primitive type
siChainRootPrimType Chain Root Primitive type
siCirclePrimType Implicit Circle Primitive type
siCloudPrimType Cloud Primitive type
siConePrimType Cone Primitive type
siCrvListAggregatePrimType NURBS Curve List Aggregate Primitive type
siCrvListPrimType NURBS Curve List Primitive type
siCubePrimType Cube Primitive type
siCylinderPrimType Cylinder Primitive type
siDiscPrimType Disc Primitive type
siDodecahedronPrimType Dodecahedron Primitive type
siDragCtrlPrimType Drag Control Primitive type
siEddyCtrlPrimType Eddy Control Primitive type
siFanType Fan Force Object type
siFurPrimType Fur Primitive type
siGeoShaderPrimType GeoShader Primitive Type
siGravityCtrlType Gravity Force Control Object type
siGridPrimType Grid Primitive type
siIcosahedronPrimType Icosahedron Primitive type
siLatticePrimType Lattice Primitive type
siLightPrimType Light Primitive type
siModelNullPrimType Model Null Primitive type
siModelType 3D Model type
siNullPrimType Null Primitive type
siOctahedronPrimType Octahedron Primitive type
siPolyMeshType Polygon Mesh type
siSpherePrimType Sphere Primitive type
siSpiralPrimType Implicit Spiral Primitive type
siSpotInterestPrimType Spot Interest Primitive type
siSpotRootPrimType Spot Root Primitive type
siSquarePrimType Implicit Square Primitive type
siSrfMeshPrimType NURBS Surface Mesh Primitive type
siTetrahedronPrimType Tetrahedron Primitive type
siTorusPrimType Torus Primitive type
siTurbulenceCtrlPrimType Turbulence Control Primitive type
siVolumeDeformType Volume Deform type (implicit sphere volume)
siVortexCtrlType Vortex Control Object type (magnetic force)
siWaveCtrlType Wave Control Object type
siWindType Wind Force Object type
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.

Possible Values:

Description:

si3DObjectFamily 3D Object family
siCameraFamily Camera family
siChainElementFamily Chain Element family
siControlObjectFamily Control Object family
siCurveFamily Curve Geometry family
siGeometryFamily Geometry family
siGeometryShaderFamily Geometry shader family
siImplicitGeometryFamily Implicit Geometry family
siLatticeFamily Lattice family
siLightPrimitiveFamily Light Primitive family
siMeshFamily Mesh Geometry family
siNullPrimitiveFamily Null Primitive family
siNurbsCurveListFamily Nurbs CurveList Geometry family
siNurbsSurfaceMeshFamily Nurbs Surface Mesh Geometry family
siSurfaceCurveFamily Surface Curve Geometry family
siSurfaceFamily Surface Geometry family
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

Examples

1. VBScript Example

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

2. JScript Example

/*
	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( "----------------------------" ) ;
}

See Also

X3DObject.Children X3DObject.FindChild EnumElements