Checking for ICE trees in the construction history


You can use the ActivePrimitive.ConstructionHistory to find out where an ICETree is in the construction stack.

var o = Dictionary.GetObject( "someobject" );
var sMarker;

oEnum = new Enumerator( o.ActivePrimitive.ConstructionHistory );
for (;!oEnum.atEnd();oEnum.moveNext())           
{
	if( oEnum.item().BelongsTo( "MarkerOperators" ) )
	{
		sMarker = oEnum.item().type;
	}
	else if (oEnum.item().IsClassOf( siICETreeID  ) == true )
	{
		LogMessage( sMarker + " -> " + oEnum.item().name );
	}
}
// INFO : simulationmarker -> ICETree1
// INFO : modelingmarker -> ICETree

And here’s a Python version courtesy of Alan Fregtman of the Softimage mailing list.
How to tell if a given ICETree object is simulated or not

# ---------------------------------
xsi = Application

obj = xsi.Selection(0)
markers = ["secondaryshapemarker","postsimulationmarker","simulationmarker","animationmarker","shapemarker","modelingmarker"]
opstack = obj.ActivePrimitive.ConstructionHistory

for op in opstack:
	if any([op.FullName.endswith("."+marker) for marker in markers]):
		lastMarker = op.FullName

	if xsi.ClassName(op) == "ICETree":
		print op.FullName+" is under marker: "+lastMarker.split(".")[-1]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s