Selection

Selection

Object Hierarchy | 関連する C++クラス:Selection

導入

v1.0

詳細

Selection オブジェクトは、アプリケーションのグローバルセレクションです。ユーザは、ビュー、Explore、MCA(メインコマンドパネル内の選択サブパネル)、およびスクリプティングを使ってグローバル選択を変更できます(SelectObjAddToSelectionRemoveFromSelectionToggleSelectionDeselectAllなどを参照)。

注:Selection は、プロパティを通してそのメンバへSelection.Itemのアクセスを可能にします。選択されている対象に応じて、Selection.ItemプロパティはオブジェクトまたはCollectionItemを戻します。たとえば、球全体を選択すると、Selection.Itemプロパティは球をX3DObjectとして戻します。ただし、エッジなどのサブコンポーネントのみを選択すると、エッジをCollectionItemとして戻します。

メソッド

Add Clear GetAsText Remove
SetAsText      
       

プロパティ

Count Filter Item  
       

1. VBScript の例

'This example demonstrates how a script can find the selected vertices 

'in a selection of multiple objects.

'Set up a little scenario 

coneName = CreatePrim( "Cone", "MeshSurface" )

sphereName = CreatePrim("Sphere", "MeshSurface" )

DeselectAll

AddToSelection coneName &".pnt[4,7,10]", , True

AddToSelection sphereName &".pnt[1,2,3]", , True

'Now iterate through the selection using the OM selection object

set oSelection = Application.Selection  

for i = 0 to (oSelection.Count - 1)  

	if ( oSelection(i).Type = "pntSubComponent" ) then

		logmessage "Found the following selected vertices on " & oSelection(i).Subcomponent.Parent3DObject.Name

		'Selection of points 

		set subComponent = oSelection(i).SubComponent

		selectedIndices = subComponent.ElementArray

		for j = 0 to Ubound( selectedIndices, 1 )

			logmessage selectedIndices(j)

		next	

	else

		logmessage "Nothing to do with " & oSelection(i).Name & "Type (" & oSelection(i).Type & ")"

	end if	

next  

'Output of the above script is:

'"Found the following selected vertices on cone"

'"4"

'"7"

'"10"

'"Found the following selected vertices on sphere"

'"1"

'"2"

'"3"

2. VBScript の例

'

' This example shows how to save the current selection into 

' an XSICollection object.  This can be very useful if you want 

' to remember what objects were selected before running 

' commands that might change the selection

'

' Note: Although this example sets up its own selection, you 

' could remove the SETUP section and run this example with

' your own selection instead.

'

' SETUP

NewScene , false

set arc = CreatePrim( "Arc", "NurbsCurve" )

set disc = CreatePrim( "Disc", "MeshSurface" )

CreatePrim "Cylinder", "MeshSurface"

set oSelection = Application.Selection

oSelection.Clear

oSelection.Add arc

oSelection.Add disc

' MAIN

Application.LogMessage "Current selection: " & oSelection.GetAsText()

strSelection = oSelection.GetAsText()

set oColl = CreateObject( "XSI.Collection" ) 

oColl.SetAsText strSelection 

Application.LogMessage "Contents of XSICollection: " & oColl.GetAsText

' RESULTS

'INFO : Current selection: arc,disc

'INFO : Contents of XSICollection: arc,disc