ProjectItem.BranchFlag operator

Description

Returns the branch flag using one of the siBranchFlag enum values. The branch flag indicates whether an object was added to a Group or to the Selection in branch mode.

Note: Four different hierarchical levels are actually recognized: NODE, BRANCH, TREE, and MODEL (see Dealing with Hierarchy). However, this property always returns the siBranch value when tested on items that are selected or added to a group in BRANCH, TREE, or MODEL mode.

Examples

1. Python Example

# 
# 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 Example

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