TrackCollection.Filter.1.vbs Example
Applies To
TrackCollection.Filter method
Description
This example demonstrates how to use the Filter method to separate specific types of objects out from the rest of the collection by families. Set up the example using a mesh grid, cube, cone, and a nurbs cube:
Code
set oRoot = ActiveSceneRoot oRoot.AddGeometry "grid", "meshsurface" oRoot.AddGeometry "cube", "meshsurface" oRoot.AddGeometry "cone", "meshsurface" oRoot.AddGeometry "cube", "nurbssurface" ' Use the X3DObject.FindChildren method, limited to geometry objects set oGeoms = oRoot.FindChildren( , , siGeometryFamily ) LogMessage "The collection of geometry objects under the root is a " & ClassName( oGeoms ) LogMessage "There are " & oGeoms.Count & " geometry objects under the root." LogMessage "" for each geomobj in oGeoms LogMessage geomobj.Name & " is a " & geomobj.Type & " " & ClassName( geomobj ) next ' Filtering by family set oNurbFam = oGeoms.Filter( , siNurbsSurfaceMeshFamily ) set oPolyFam = oGeoms.Filter( , siMeshFamily ) ' Filtering by type set oCones = oGeoms.Filter( "cone" ) set oCubes = oGeoms.Filter( "cube" ) ' Filtering by both gives you a more narrow hitlist set oPolyCubes = oGeoms.Filter( "cube", siMeshFamily ) ' Now print out the results 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 objects under the root is a X3DObjectCollection 'INFO : There are 10 geometry objects under the root. 'INFO : 'INFO : MySuperCone is a polymsh X3DObject 'INFO : MySuperCylinder is a polymsh X3DObject 'INFO : MyAwesomeCone is a surfmsh X3DObject 'INFO : MySuperTorus is a surfmsh X3DObject 'INFO : MyAwesomeTorus is a polymsh X3DObject 'INFO : MyImplicitCube is a cube X3DObject '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: 10 'INFO : Number of Nurbs objects in collection: 3 'INFO : Number of Mesh objects in collection: 6 'INFO : Number of cones in collection: 3 'INFO : Number of cubes in collection: 3 'INFO : Number of Mesh cubes in collection: 1
Related Examples
Keywords
TrackCollection Filter
Autodesk Softimage 2011