階層の操作

 
 
 

選択では、オブジェクトの階層の 4 つの異なるレベル(選択モード)を認識します。 特定の操作(オペレータの適用など)では、これらの操作の範囲が変更されるため、選択モードが重要になります。

注:

Softimage における階層の選択についての一般情報は、『Softimage ユーザ ガイド』の「階層でオブジェクトを選択する」を参照してください。

選択の際に階層を指定する

SelectObj コマンドと Selection.Add または Selection::Add メソッドのどちらを使用しても、以下の階層モードを指定できます。

注:

階層キーワードをサポートするコマンドは、他にも AddToSelectionToggleSelectionSelectNeighborObj などいくつかあります。

その他、SelectBranchSelectTreeSelectModelなども階層選択の指定に便利です。

ヒント:

さらに、項目をブランチ選択するか、選択から独立させるかを指定する別の方法もあります。

階層を使用したオブジェクトを削除する

ほとんどの場合、オブジェクトの削除はオブジェクト名を DeleteObj コマンドに渡すだけで簡単に行うことができます。 ただし、オブジェクトに他の 3D オブジェクトが含まれている場合は、以下の特別な手順に従う必要があります。

  • 削除するオブジェクトがモデルまたはヌルの場合は、ブランチ削除によってそのオブジェクトとその子を削除する必要があります。 モデルまたはヌルは、ブランチ削除以外の方法では削除されません。

  • ブランチ削除によって他の 3D オブジェクト(球、円錐など)を削除すると、そのオブジェクトと、含まれるノードがすべて削除されます。ノード削除によって削除すると、そのオブジェクトが削除され、同名のヌルに置き換わります。これは、含まれているノードの階層を維持するためです。

オブジェクトをブランチ削除で削除するためには、そのオブジェクトをブランチ内で選択して引数を指定せずに DeleteObj コマンドを実行するか、削除するオブジェクトの名前を指定してブランチ プリフィックス "B:" を使用する必要があります。 たとえば以下のようになります。

JScript の例: モデルの削除(ノードとブランチ)

// Create a simple model containing a sphere
NewScene(null, false);
var sph = CreatePrim("Sphere", "MeshSurface");
var mdl = CreateModel(sph, "LocalModel")(0);
Application.LogMessage(Application.ActiveSceneRoot.Models.GetAsText());
// INFO : LocalModel

// First node-delete it (nothing happens)
DeleteObj(mdl);
Application.LogMessage(Application.ActiveSceneRoot.Models.GetAsText());
// INFO : LocalModel

// Then try branch-deleting it (it is removed)
SelectObj(mdl, "BRANCH")// models must be branch-selected when deleting
DeleteObj();
Application.LogMessage(Application.ActiveSceneRoot.Models.GetAsText());
// INFO :
注:

"B:" プリフィックスを DeleteObj コマンドで使用する方法の例は、「VBScript の例: ブランチでヌルを削除する」を参照してください。

階層の選択をテストする

各 3D オブジェクトは、そのオブジェクトがノード選択されているかどうかを記憶するために、オブジェクト固有の ProjectItem.BranchFlag または ProjectItem::GetBranchFlag を格納します。 つまり、オブジェクトがブランチ、ツリー、またはモデルで選択されている場合、ブランチ フラグは 1 になります。 オブジェクトがノード選択のみされている場合は、ブランチ フラグは 0 に設定されます。

重要:

パラメータおよびコンパウンド プロパティは選択できないので注意してください。これらの 3dobject が選択されますが、マークとして認識されます。 SDK では、パラメータは SIObject または SIObject クラスから派生します。しかし、それは、ProjectItem または ProjectItem クラスで、ProjectItem.BranchFlag または ProjectItem::GetBranchFlag プロパティを実装します。

Python での階層選択のテスト例は、「Python の例: 階層の選択項目をテストする」を参照してください。

階層およびサブコンポーネント

ポイント、エッジ、ポリゴンなどは、個別のサブコンポーネントであるため、どの階層モードもサポートしません。階層が重要となるのは、シーン アイテムに対して操作を行う場合(ブランチ内でのオペレータの適用など)だけです。

以下の例を参考にしてください。

JScript の例: SelectObj コマンドを使用した階層選択

この例は、SelectObj コマンドを使用してさまざまな階層モードでオブジェクトを選択する方法を示します。

// Set up a scene with lots of hierarchy 
SetUpScene();

// Try the different modes with the SelectObj command

SelectObj("Herman.Larm", "NODE");
Application.LogMessage(Selection.GetAsText());
// INFO : Herman.LArm

SelectObj("Herman.Larm", "BRANCH");
Application.LogMessage(Selection.GetAsText());
// INFO : Herman.LArm

SelectObj("Herman.Larm", "TREE");
Application.LogMessage(Selection.GetAsText());
// INFO : Herman.Arms

SelectObj("Herman.Larm", "MODEL");
Application.LogMessage(Selection.GetAsText());
// INFO : Herman


// --------------------------
//	Convenience function
//
function SetUpScene()
{
	NewScene(null, false);

	// Topmost level
	CreateModel("", "Herman");

	// General body parts
	GetPrim("Null", "Head", "Herman");
	GetPrim("Null", "Chest", "Herman");
	GetPrim("Null", "Arms", "Herman");
	GetPrim("Null", "Torso", "Herman");
	GetPrim("Null", "Legs", "Herman");

	// Individual body parts
	GetPrim("Null", "LArm", "Herman.Arms");
	GetPrim("Null", "RArm", "Herman.Arms");

	// Specific body parts
	CreatePrim("Sphere", "MeshSurface", "Bicep", "Herman.Larm");
	Scale("Herman.Bicep", 0.35, 1, 0.35, siAbsolute, siPivot, siObj, siXZ);
}

Python の例: Selection.Add メソッドを使用した階層選択

siSelectMode 値を、Selection.Add または Selection::Add(SelectObj コマンドではなく)とともに使用します。

from win32com.client import constants as xsi
app = Application

# --------------------------
#	Convenience function
#
def SetUpScene() :
	Application.NewScene("", 0)

	# Topmost level
	Application.CreateModel("", "Herman")

	# General body parts
	Application.GetPrim("Null", "Head", "Herman")
	Application.GetPrim("Null", "Chest", "Herman")
	Application.GetPrim("Null", "Arms", "Herman")
	Application.GetPrim("Null", "Torso", "Herman")
	Application.GetPrim("Null", "Legs", "Herman")

	# Individual body parts
	oRefObj = app.GetPrim("Null", "LArm", "Herman.Arms")
	Application.GetPrim("Null", "RArm", "Herman.Arms")

	# Specific body parts
	Application.CreatePrim("Sphere", "MeshSurface", "Bicep", "Herman.Larm")
	Application.Scale("Herman.Bicep", 0.35, 1, 0.35, "siAbsolute", "siPivot", "siObj", "siXZ")
	
	return oRefObj


# --------------------------
#	Hierarchical selection
#
# Set up a scene with lots of hierarchy 
o3DSceneItem = SetUpScene()

# Try the different modes with the Selection.Add method
oSel = app.Selection

oSel.Clear()
oSel.Add(o3DSceneItem, xsi.siSelectNode)
app.LogMessage(oSel.GetAsText())
# INFO : Herman.LArm

oSel.Clear()
oSel.Add(o3DSceneItem, xsi.siSelectBranch)
app.LogMessage(oSel.GetAsText())
# INFO : Herman.LArm

oSel.Clear()
oSel.Add(o3DSceneItem, xsi.siSelectTree)
app.LogMessage(oSel.GetAsText())
# INFO : Herman.Arms

oSel.Clear()
oSel.Add(o3DSceneItem, xsi.siSelectModel)
app.LogMessage(oSel.GetAsText())
# INFO : Herman

VBScript の例: ブランチでのヌルの削除

この例では、オブジェクトの文字列式に"B:"ブランチ プリフィックスを指定して、オブジェクトとその子を削除する方法を示します。

set app = Application
NewScene , false

GetPrim "Null", "top"
GetPrim "Null", "middle_1", "top"
GetPrim "Null", "middle_2", "top"
GetPrim "Null", "middle_3", "top"
GetPrim "Null", "mid_2_bottom_1", "middle_2"
GetPrim "Null", "way_low", "mid_2_bottom_1"
GetPrim "Null", "mid_2_bottom_2", "middle_2"
GetPrim "Null", "mid_3_bottom", "middle_3"

SelectAll
app.LogMessage "There are currently " & app.Selection.Count & " item(s) selected."
for each sel_item in app.Selection
	app.LogMessage sel_item.Name
next
' INFO : There are currently 12 item(s) selected.
' INFO : Camera_Root
' INFO : Camera
' INFO : Camera_Interest
' INFO : light
' INFO : top
' INFO : middle_1
' INFO : middle_2
' INFO : mid_2_bottom_1
' INFO : way_low
' INFO : mid_2_bottom_2
' INFO : middle_3
' INFO : mid_3_bottom


' Now delete the entire middle_2 branch
DeleteObj "B:middle_2"
app.LogMessage "There are currently " & app.Selection.Count & " item(s) selected."
for each sel_item in app.Selection
	app.LogMessage sel_item.Name
next
' INFO : There are currently 8 item(s) selected.
' INFO : Camera_Root
' INFO : Camera
' INFO : Camera_Interest
' INFO : light
' INFO : top
' INFO : middle_1
' INFO : middle_3
' INFO : mid_3_bottom

Python の例: 階層で選択されたアイテムのテスト

この例では、選択したアイテムを繰り返し処理し、各アイテムがノード選択されているかどうかをテストする方法を示します。

app = Application

# --------------------------
#	Convenience function
#
def SetUpMultiLevelNulls() :
	app.NewScene("", 0)
	app.CreateModel("", "TopDog")
	
	# Create a hierarchy to test
	app.CreateModel("", "NextLevel")
	app.GetPrim("Null", "HigherLevel", "NextLevel")
	targetObj = app.GetPrim("Null", "MidLevel", "NextLevel.HigherLevel")
	app.GetPrim("Null", "LowerLevel", "NextLevel.MidLevel")
	app.GetPrim("Null", "BottomFeeder", "NextLevel.LowerLevel")
	app.CreateModel(app.ActiveSceneRoot.Models(0), "TopDog")

	
	return targetObj


# --------------------------
#	Hierarchical selection
#
def TestSelection() :
	for thing in app.Selection :
		if ( thing.BranchFlag ) :
			app.LogMessage( thing.Name + " is selection in BRANCH" )
		else :
			app.LogMessage( thing.Name + " is selection in NODE" )


# --------------------------
#	Logging results
#
# NODE-selected
refObj = SetUpMultiLevelNulls()
app.SelectObj( refObj.FullName )
TestSelection()	# INFO : MidLevel is selection in NODE

# BRANCH-selected
refObj = SetUpMultiLevelNulls()
app.SelectObj( "B:" + refObj.FullName )
TestSelection()	# INFO : MidLevel is selection in BRANCH

# TREE-selected
refObj = SetUpMultiLevelNulls()
app.SelectObj( "B:" + refObj.FullName, "TREE" )
TestSelection()	# INFO : HigherLevel is selection in BRANCH

# MODEL-selected
refObj = SetUpMultiLevelNulls()
app.SelectObj( "B:" + refObj.FullName, "MODEL" )
TestSelection()	# INFO : NextLevel is selection in BRANCH