ParameterCollection.Find.1.vbs Example
Applies To
ParameterCollection.Find method
Description
This example demonstrates how to find X3DObject objects 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" 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"
Related Examples
Keywords
ParameterCollection Find
Autodesk Softimage 2011