Correct me if I am wrong,
but my understanding was that nested collections are not supported.
From:
owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of Bernard Lebel
Sent: May 9, 2007 4:09 PM
To: XSI(at)Softimage.COM
Subject: [script] Nested
XSICollections
Hello,
Anyone ever had troubles with nested XSICollections?
I have this piece of code:
var oModels = XSIFactory.createobject( "XSI.Collection"
);
var oObject, sObjectName, oModel, sModelName, oModelColl,
oObjectColl, eModelColls, bNew, oGroup, sGroupName, i, iCount;
// Enumerate selected objects
for( var eSel = new Enumerator( selection ); !eSel.atEnd();
eSel.moveNext() )
{
oObject = eSel.item();
sObjectName = oObject.name;
// Check if object is a model
if( oObject.type == siModelType )
{
//logmessages( '<
ts_CreateCTRLGroup > :: Object "' + oObject.fullname + '" is a
model, skipped.', siWarning );
}
else
{
oModel =
oObject.model;
sModelName =
oModel.fullname;
bExists = false;
// Check if this model
has been collected
iCount =
oModels.count;
if( iCount < 1 )
{
//
Create a new collection for this model
oModelColl = XSIFactory.createobject( "XSI.Collection" );
//
Create collection where only the current object will be put
oObjectColl = XSIFactory.createobject( "XSI.Collection" );
oModelColl.items = oModel;
oObjectColl.items = oObject;
//
Add the object collection after the model object, in the model collection
oModelColl.add( oObjectColl );
//
Store this entire model collection in the main collection
oModels.add( oModelColl );
}
else
{
bNew = true;
//
Enumerate the model collections
for( eModelColls = new Enumerator( oModels ); !eModelColls.atEnd();
eModelColls.moveNext () )
{
// Get single model collection
oModelColl = eModelColls.item();
logmessage( oModelColl.items );
if( oModelColl(0).fullname == sModelName )
{
}
}
if(
bNew == true )
{
// Create a new collection for this model
oModelColl = XSIFactory.createobject(
"XSI.Collection" );
// Create collection where only the current object will be
put
oObjectColl = XSIFactory.createobject(
"XSI.Collection" );
oModelColl.items = oModel;
oObjectColl.items = oObject;
// Add the object collection after the model object, in the
model collection
oModelColl.add( oObjectColl );
// Store this entire model collection in the main collection
oModels.add( oModelColl );
}
}
}
}
The problematic lines are marked with a // BIG PROBLEMS notation.
The first one, logmessage( oModelColl.items ); prints an empty string.
The second raises an error: //ERROR : Object not a collection - [line 78]
I would expect the line oModelColl = eModelColls.item() to return a
XSICollection, but it seem not....
Any suggestion?
Thanks
Bernard