ClusterPropertyCollection.Find

Description

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

C# Syntax

ClusterProperty ClusterPropertyCollection.Find( String in_filter );

Scripting Syntax

oReturn = ClusterPropertyCollection.Find( [Type] );

Return Value

Object (type varies according to find criteria).

Parameters

Parameter Type Description
Type String Object type (see siType for a list of possible values)

Examples

1. VBScript Example

'
'	This example demonstrates how to find X3DObject objects
'
' 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"

2. JScript Example

/*
	This example demonstrates how to find Cluster objects
*/
NewScene( null, false );
var obj = CreatePrim( "Cube", "MeshSurface" );
CreateCluster("cube.pnt[2,3,6,LAST]");
CreateCluster("cube.poly[1]");
CreateCluster("cube.edge[0,1,3,5-8,LAST]");
CreateCluster("cube.sample[0,3-9,12,15,20,21]");
// find the cluster using the siType constant.
var cls = obj.activeprimitive.geometry.clusters.find( siPolygonCluster );
if ( cls != null )
	logmessage( "found polygon cluster: " + cls.fullname ); 
//Expected results:
//INFO : found polygon cluster: cube.polymsh.cls.Polygon

3. Python Example

#
# 	This example demonstrates how to to find PlayControl Property objects 
# 	under the scene root
#
PlayCtrlProp = Application.ActiveProject.Properties.Find( "PlayControl" )
try :
	if Application.ClassName(PlayCtrlProp) == "Property" :
		Application.LogMessage( "PlayControl property OK" )
	else :
		Application.LogMessage( "PlayControl property NOT found" )
except :
	Application.LogMessage( "PlayControl property NOT found" )
# Output of above script:
#INFO : PlayControl property OK