このコレクションのサブセットを、フィルタ基準に一致するX3DObjectオブジェクトの新しいコレクションとして戻します。項目が検出されなかった場合、このファイルは"Nothing"を戻すので、エラーの捕捉に使用できます。
X3DObjectCollection X3DObjectCollection.Filter( String in_filter, Object in_famArray, String in_path ); |
oReturn = X3DObjectCollection.Filter( [Type], [Families], [Path] ); |
X3DObject オブジェクトのコレクションです。
パラメータ | タイプ | 説明 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Type | String |
siType で定義されているオブジェクトのタイプ。タイプを使用しない場合は空の文字列になります。タイプには、特定の x3DObject タイプ(siModelType、si3DObjectType など)とプリミティブタイプ(siPolyMeshType、siSrfMeshPrimType など)があります。プリミティブタイプを指定した場合は、このタイプのプリミティブが定義されているオブジェクトのみが関数の対象になります。
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Families | siFamily |
siFamily で定義されているファミリの配列、必要ない場合は空の配列。ファミリを使用して検索を絞り込みます。配列には、X3DObject ファミリ(si3DObjectFamily など)やプリミティブファミリ(siNurbsSurfaceMeshFamily、siNullPrimitiveFamily など)があります。指定されたファミリに一致するオブジェクトだけが処理されます。プリミティブファミリを指定した場合は、そのファミリのいずれかに属するプリミティブが定義されているオブジェクトのみが対象になります。
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Path | String | Object Name。ワイルドカードを使用して、部分一致名を指定できます。たとえば、"a*"と指定すると、文字"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 )" |