ProjectItem.BranchFlag operator

説明

siBranchFlag 列挙型の値の 1 つを使用して、ブランチフラグを戻します。ブランチフラグは、オブジェクトが Group またはブランチモードの Selection のどちらに追加されたかを示します。

注:NODE、BRANCH、TREE、および MODEL の 4 つの階層レベルが実際に認識されます(「Dealing with Hierarchy」を参照してください。ただし、BRANCH、TREE、または MODEL モードで選択またはグループに追加されたアイテム上でテストしている場合は、このプロパティは常に siBranch 値を戻します。

C#構文

// get accessor

siBranchFlag rtn = ProjectItem.BranchFlag;

// set accessor

ProjectItem.BranchFlag = siBranchFlag;

1. Python の例

# 

# This example demonstrates how to test each selected item to see whether

# it is selected in branch (BRANCH/TREE/MODEL) or not.

#

from win32com.client import constants as cns

app = Application

# Create a bunch of objects for selection tests

app.NewScene("", 0)

app.CreatePrim("Disc", "MeshSurface")

app.CreatePrim("Torus", "MeshSurface")

app.CreatePrim("Grid", "MeshSurface")

app.CreatePrim("Sphere", "MeshSurface")

app.CreatePrim("Cube", "MeshSurface")

app.CreatePrim("Cone", "MeshSurface")

# Select a number of objects with different hierarchical levels

app.SelectObj("disc", "BRANCH")

app.AddToSelection("torus", "TREE")

app.AddToSelection("grid", "NODE")

app.AddToSelection("sphere", "MODEL")

app.AddToSelection("cube")

for sel in app.Selection :

	strResults = ""

	if sel.BranchFlag == 0 :

		strResults = "siNode"

	elif sel.BranchFlag == 1 :

		strResults = "siBranch"

	elif sel.BranchFlag == 3 :

		strResults = "siUnspecified"

	else :

		strResults = "<unrecognized value>"

	app.LogMessage( sel.FullName + ".BranchFlag == " + strResults )

# Expected results:

# INFO : disc.BranchFlag == siBranch

# INFO : torus.BranchFlag == siBranch

# INFO : grid.BranchFlag == siNode

# INFO : sphere.BranchFlag == siBranch

# INFO : cube.BranchFlag == siNode

2. JScript の例

var xsi = Application;

NewScene( null, false );

var a = xsi.ActiveSceneRoot.AddGeometry( "Cube", "MeshSurface", "A" );

a.length.Value = 2;

var b = a.AddGeometry( "Cube", "MeshSurface", "B" );

b.length.Value = 2;

Translate( b, 5 );

var c = b.AddGeometry( "Cube", "MeshSurface", "C" );

c.length.Value = 2;

Translate( c, 5 );

// Create group

var group = xsi.ActiveSceneRoot.AddGroup();

// Add members to group

group.AddMember( a, true );

group.AddMember( b, false );

xsi.LogMessage( "Number of group members : " + group.members.Count );

// Determine which members were added in branch mode

for ( var i=0; i<group.Members.Count; i++ )

{

	var member = group.Members(i);

	var bBranchMember = group.Members(i).BranchFlag ? "true" : "false";

	xsi.LogMessage( member + " added in branch mode? " + bBranchMember );

}

// Expected results:

//INFO : Number of group members : 2

//INFO : A added in branch mode? true

//INFO : B added in branch mode? false