Re: [Scripting] FindChildren with Annotations....

Date : Wed, 2 May 2007 12:45:10 -0400
To : XSI(at)Softimage.COM
From : "Bernard Lebel" <3dbernard(at)gmail.com>
Subject : Re: [Scripting] FindChildren with Annotations....
Perhaps a simpler and more cost effective way to do it:

var oColl = XSIFactory.createobject( "XSI.Collection" );
oColl.items = activesceneroot.name + ".Annotation";

if( oColl.count > 0 )
   logmessage( "already exists" );
else
   do something


Cheers Bernard




On 5/2/07, Dan Yargici <danyargici(at)gmail.com> wrote:
Actually, while you're feeling generous... ;)

It'd be good to get some feedback as I go so I can cleanup as I go...
Actually this will probably get canned for something using the last example
you sent, but still.... any glaring mistakes?  The reason I used a "for (i
=0;.... " loop is because it refused to work using "for(myObj in myCol)" - I
have no idea why....

//---Begins here---

var myScnroot = ActiveProject.ActiveScene.Root;
var myAnotnName = "PluginData";
var myRealPlug;
var myString = "";

if(!ifDataExist(myAnotnName))
{
     var myAnotn = AddProp( "Annotation", myScnroot, siDefaultPropagation,
myAnotnName );
}

var myPlugCol = Application.Plugins;
var myCountCol = new ActiveXObject("XSI.Collection");
for (i = 0; i < myPlugCol.count; i++)
{
    var myPlug = myPlugCol.Item(i);

    if (myPlug.loaded)
    {
        var myOrig = myPlug.origin;
        if (myOrig == 1 || myOrig == 2 || myOrig == 5 || myOrig == 6)
         {
            myCountCol.Add(myPlug);
        }
    }
}

for (i = 0; i < myCountCol.count; i++)
{
    var myRealPlug = myCountCol.item(i);
    myString = myString+myRealPlug+"\r\n"
}

//Workgroups

var myWrkgrps = new VBArray( Application.Workgroups );
var cntWrkgrps = myWrkgrps.ubound( 1 ) + 1

myString = myString + "\r\nXSI was connected to these workgroups at save
time:";
for (i = 0; i < cntWrkgrps; i++)
{
    myString = myString +
"\r\n*"+myWrkgrps.getItem(i)+"\r\n";
}

logmessage ("\r\n"+myString);

SetValue(myAnotnName+".text", myString, null);



//----------------------FUNCTIONS--------------------------------

function ifDataExist()
{
       myScnroot = ActiveProject.ActiveScene.Root;
       result = 0;

       oEnum = new Enumerator( myScnroot.properties ) ;
       for (;!oEnum.atEnd();oEnum.moveNext() )
       {
               var oProp = oEnum.item() ;
               if(oProp.Name == myAnotnName )
               {

LogMessage("\r\n-------------------------------------------")
                       LogMessage("Annotation exists -
Re-using...\r\n-------------------------------------------")
                       result = 1;
               }
       }
       return result
}



---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.