X3DObjectCollection.Filter

説明

このコレクションのサブセットを、フィルタ基準に一致するX3DObjectオブジェクトの新しいコレクションとして戻します。項目が検出されなかった場合、このファイルは"Nothing"を戻すので、エラーの捕捉に使用できます。

C#構文

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 など)があります。プリミティブタイプを指定した場合は、このタイプのプリミティブが定義されているオブジェクトのみが関数の対象になります。

指定可能な値:

説明:

siPolyMeshType Polygon Mesh タイプ
si3DObjectType 3D Object タイプ
siArcPrimType Implicit Arc Primitive タイプ
siAttractorCtrlType Attractor Control Object タイプ(電気力)
siCameraPrimType Camera Primitive タイプ
siCameraRootPrimType Camera Root primitive タイプ
siChainBonePrimType Chain Bone Primitive タイプ
siChainEffPrimType Chain End Effector Primitive タイプ
siChainRootPrimType Chain Root Primitive タイプ
siCirclePrimType Implicit Circle Primitive タイプ
siCloudPrimType Cloud Primitive タイプ
siConePrimType Cone Primitive タイプ
siCrvListAggregatePrimType NURBS Curve List Aggregate Primitive タイプ
siCrvListPrimType NURBS Curve List Primitive タイプ
siCubePrimType Cube Primitive タイプ
siCylinderPrimType Cylinder Primitive タイプ
siDiscPrimType Disc Primitive タイプ
siDodecahedronPrimType Dodecahedron Primitive タイプ
siDragCtrlPrimType Drag Control Primitive タイプ
siEddyCtrlPrimType Eddy Control Primitive タイプ
siFanType Fan Force Object タイプ
siFurPrimType Fur Primitive タイプ
siGeoShaderPrimType GeoShader Primitive タイプ
siGravityCtrlType Gravity Force Control Object タイプ
siGridPrimType Grid Primitive タイプ
siIcosahedronPrimType Icosahedron Primitive タイプ
siLatticePrimType Lattice Primitive タイプ
siLightPrimType Light Primitive タイプ
siModelNullPrimType Model Null Primitive タイプ
siModelType 3D Model タイプ
siNullPrimType Null Primitive タイプ
siOctahedronPrimType Octahedron Primitive タイプ
siPointCloudPrimType PointCloud プリミティブタイプ
siSpherePrimType Sphere Primitive タイプ
siSpiralPrimType Implicit Spiral Primitive タイプ
siSpotInterestPrimType Spot Interest Primitive タイプ
siSpotRootPrimType Spot Root Primitive タイプ
siSquarePrimType Implicit Square Primitive タイプ
siSrfMeshPrimType NURBS Surface Mesh Primitive タイプ
siTetrahedronPrimType Tetrahedron Primitive タイプ
siTorusPrimType Torus Primitive タイプ
siTurbulenceCtrlPrimType Turbulence Control Primitive タイプ
siVolumeDeformType Volume Deform タイプ(インプリシット球のボリューム)
siVortexCtrlType Vortex Control Object タイプ(磁力)
siWaveCtrlType Wave Control Object タイプ
siWindType Wind Force Object タイプ
Families siFamily siFamily で定義されているファミリの配列、必要ない場合は空の配列。ファミリを使用して検索を絞り込みます。配列には、X3DObject ファミリ(si3DObjectFamily など)やプリミティブファミリ(siNurbsSurfaceMeshFamily、siNullPrimitiveFamily など)があります。指定されたファミリに一致するオブジェクトだけが処理されます。プリミティブファミリを指定した場合は、そのファミリのいずれかに属するプリミティブが定義されているオブジェクトのみが対象になります。

指定可能な値:

説明:

si3DObjectFamily 3D Object ファミリ
siCameraFamily Camera ファミリ
siChainElementFamily Chain Element ファミリ
siControlObjectFamily Control Object ファミリ
siCurveFamily Curve Geometry ファミリ
siGeometryFamily Geometry ファミリ
siGeometryShaderFamily Geometry Shader ファミリ
siImplicitGeometryFamily Implicit Geometry ファミリ
siLatticeFamily Lattice ファミリ
siLightPrimitiveFamily Light Primitive ファミリ
siMeshFamily Mesh Geometry ファミリ
siNullPrimitiveFamily Null Primitive ファミリ
siNurbsCurveListFamily Nurbs CurveList Geometry ファミリ
siNurbsSurfaceMeshFamily Nurbs Surface Mesh Geometry ファミリ
siPointCloudFamily Point Cloud ファミリ
siSurfaceCurveFamily Surface Curve Geometry ファミリ
siSurfaceFamily Surface Geometry ファミリ
Path String Object Name。ワイルドカードを使用して、部分一致名を指定できます。たとえば、"a*"と指定すると、文字"a"で始まるすべての一致オブジェクトが戻されます。

1. VBScript の例

'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"

2. VBScript の例

'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 )"