X3DObjectCollection.Find
 
 
 

X3DObjectCollection.Find

Description

Returns the first member of this collection that matches the type criteria. If no item is found, it returns "Nothing", which you can use to trap errors.

C# Syntax

X3DObject X3DObjectCollection.Find( String in_filter );

Scripting Syntax

oReturn = X3DObjectCollection.Find( [Type] );

Return Value

X3DObject

Parameters

Parameter Type Description
Type siType The type of object to look for defined by siType or an empty string if the type is not required. 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 returns the first child object defined with a primitive of this type.

Possible Values:

Description:

siPolyMeshType Polygon Mesh type
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
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

Examples

VBScript Example

'VBScript example
' Set up the example using a mesh grid, cube, cone, and a nurbs cube:
set oRoot = activesceneroot
oRoot.addgeometry "grid", "meshsurface"
oRoot.addgeometry "cube", "meshsurface"
oRoot.addgeometry "cone", "meshsurface"
oRoot.addgeometry "cube", "nurbssurface"
set oGeoms = oRoot.findchildren( ,,siGeometryFamily)
logmessage "The collection of geometry from the root is a " & typename( oGeoms ) 
logmessage "There are " & oGeoms.count & " geometry objects under the root." 
logmessage ""
for each item in oGeoms
        logmessage item.name & " is a " & item.type & " " & typename( item )
next
set oCone = oGeoms.find( "cone" )
set oCube = oGeoms.find( "cube" )
set oGrid = oGeoms.find( "grid" )
logmessage ""
logmessage "=========================================================================="
logmessage " Stats for the collection:"
logmessage " ------------------------"
logmessage "    Total number of objects in collection: " & oGeoms.count
logmessage "    Name of the first cone in the collection: " & oCone.name
logmessage "    Name of the first cube in the collection: " & oCube.name
' Try some error trapping ( if you are trying to use a find criteria that returns Nothing, 
' you will see this error message: 'ERROR : "Object required: 'oCube1'" )
set oCube1 = oGeoms.find( "cube1" )
if typename( oCube1 ) = "Nothing" then
        logmessage "    Can't get the name of the other cube in the collection."
else 
        logmessage "    Name of the other cube in the collection: " & oCube1.name
end if
logmessage "    Name of the first grid in the collection: " & oGrid.name
' Output of above script is:
'INFO : "The collection of geometry from the root is a X3DObjectCollection"
'INFO : "There are 4 geometry objects under the root."
'INFO : ""
'INFO : "grid is a polymsh X3DObject"
'INFO : "cube is a polymsh X3DObject"
'INFO : "cone is a polymsh X3DObject"
'INFO : "cube1 is a surfmsh X3DObject"
'INFO : ""
'INFO : "=========================================================================="
'INFO : " Stats for the collection:"
'INFO : " ------------------------"
'INFO : "       Total number of objects in collection: 4"
'INFO : "       Name of the first cone in the collection: cone"
'INFO : "       Name of the first cube in the collection: cube"
'INFO : "       Can't get the name of the other cube in the collection."
'INFO : "       Name of the first grid in the collection: grid"