Returns a subset of this collection as a new collection of X3DObject objects matching the filter criteria. If no items are found, Filter returns "Nothing", which you can use to trap errors.
X3DObjectCollection X3DObjectCollection.Filter( String in_filter, Object in_famArray, String in_path ); |
oReturn = X3DObjectCollection.Filter( [Type], [Families], [Path] ); |
Collection of X3DObject objects.
Parameter | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 objects
defined with a primitive of this type.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Families | siFamily | 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 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.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Path | String | An Object Name. This can be a partial name using wildcards. For example, "a*" returns all matches that begin with the character "a". |
'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 oNurbFam = oGeoms.filter( ,siNurbsSurfaceMeshFamily ) set oPolyFam = oGeoms.filter( ,siMeshFamily ) set oCones = oGeoms.filter( siConePrimType ) set oCubes = oGeoms.filter( siCubePrimType ) set oPolyCubes = oGeoms.filter( siCubePrimType, siMeshFamily ) logmessage "" logmessage "==========================================================================" logmessage " Stats for the collection:" logmessage " ------------------------" logmessage " Total number of objects in collection: " & oGeoms.count logmessage " Number of Nurbs objects in collection: " & oNurbFam.count logmessage " Number of Mesh objects in collection: " & oPolyFam.count logmessage " Number of cones in collection: " & oCones.count logmessage " Number of cubes in collection: " & oCubes.count logmessage " Number of Mesh cubes in collection: " & oPolyCubes.count ' 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 : " Number of Nurbs objects in collection: 1" 'INFO : " Number of Mesh objects in collection: 3" 'INFO : " Number of cones in collection: 1" 'INFO : " Number of cubes in collection: 2" 'INFO : " Number of Mesh cubes in collection: 1" |
'VBScript example function create_scene() NewScene , false set root = ActiveProject.ActiveScene.Root call root.AddGeometry( "cone", "meshsurface", "MySuperCone" ) call root.AddGeometry( "Cylinder", "meshsurface", "MySuperCylinder" ) call root.AddGeometry( "cone", "nurbssurface", "MyAwesomeCone" ) call root.AddGeometry( "Torus", "nurbssurface", "MySuperTorus" ) call root.AddGeometry( "Torus", "meshsurface", "MyAwesomeTorus" ) call root.AddPrimitive( "cube", "MyImplicitCube" ) call root.AddNull( "MyAwesomeNull" ) call root.AddCameraRig( "Camera" ) set create_scene = root end function function WriteCollection( in_collection, in_text ) on error resume next LogMessage "-----" LogMessage in_text size = in_collection.count LogMessage "size of collection: " & size if size = 0 then exit function end if for each i in in_collection LogMessage i.type & ":" & i.name next end function set coll = create_scene().children arr = Array(siNurbsSurfaceMeshFamily,siNullPrimitiveFamily) WriteCollection coll.filter( , ,"*Cone" ), "filter( , ,*Cone )" WriteCollection coll.filter( , ,"MyAwesome*" ), "filter( ,,*Awesome* )" WriteCollection coll.filter( siConePrimType, arr,"MyAwesome*" ), "filter( Cone, Array(siNurbsSurfaceMeshFamily,siNullPrimitiveFamily), MyAwesome* )" WriteCollection coll.filter( siConePrimType, arr ), "filter( Cone, Array(siNurbsSurfaceMeshFamily,siNullPrimitiveFamily) )" WriteCollection coll.filter( siConePrimType, siNurbsSurfaceMeshFamily ), "filter( siConePrimType, siNurbsSurfaceMeshFamily )" WriteCollection coll.filter( siConePrimType ), "filter( Cone )" WriteCollection coll.filter( siTorusPrimType, ,"*Super*" ), "filter( Torus, ,*Super* )" WriteCollection coll.filter( , siNurbsSurfaceMeshFamily ), "filter( , siNurbsSurfaceMeshFamily )" WriteCollection coll.filter( , siMeshFamily ), "filter( , siMeshFamily )" WriteCollection coll.filter( , siMeshFamily,"*Cone" ), "filter( , siMeshFamily, *Cone )" |