  | | | FX tree : Select file input node only | FX tree : Select file input node only 2005-06-15 - By kim aldis
Back you're looping through a list of items but changing that list as you loop through it so it's count and item order is changing as you go. There's a few ways to deal with this, either push the items you want to delete onto an array in the main loop then delete the items in that array after the loop, or make a copy of the selection first and loop through that. Try this:- var oColl = new ActiveXObject( "XSI.Collection" ); oColl.items = selection; // selected items into collection // loop through the collection. No reason not to use a traditional integer loop for this but this is faster. // for ( var f=new Enumerator( oColl ); !f.atEnd(); f.moveNext() ) { var oItem = f.item(); if ( oItem.type != "FileInputOp" ) { removefromselection( oItem ); } }
__ __
From: owner-xsi@(protected) [mailto:owner-xsi@(protected)] On Behalf Of guillaume laforge Sent: 15 June 2005 10:05 To: XSI@(protected) Subject: FX tree : Select file input node only
Hi List, I need to select all the file input nodes from a fxtree. The script I write below seems to remove randomly some nodes ??? I don't understand why ?
//All the Fx tree nodes are selected. var oSel = Selection; for(i=0;i<oSel.count;i++) if(oSel(i).type != "FileInputOp") { RemoveFromSelection(oSel(i)) } logmessage("only file input nodes are selected !")
Any idea ?
Cheers,
Guillaume Laforge CG artist www.vol2nuit.fr
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=us-ascii"> <META content="MSHTML 6.00.2900.2627" name=GENERATOR></HEAD> <BODY> <DIV dir=ltr align=left><SPAN class=765042009-15062005><FONT face=Arial color=#0000ff size=2>you're looping through a list of items but changing that list as you loop through it so it's count and item order is changing as you go. There's a few ways to deal with this, either push the items you want to delete onto an array in the main loop then delete the items in that array after the loop, or make a copy of the selection first and loop through that.</FONT></SPAN></DIV> <DIV dir=ltr align=left><SPAN class=765042009-15062005><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV dir=ltr align=left><SPAN class=765042009-15062005><FONT face=Arial color=#0000ff size=2>Try this:-</FONT></SPAN></DIV> <DIV dir=ltr align=left><SPAN class=765042009-15062005><FONT face=Arial color=#0000ff size=2></FONT></SPAN> </DIV> <DIV dir=ltr align=left><SPAN class=765042009-15062005><FONT face=Arial color=#0000ff size=2>var oColl = new ActiveXObject( "XSI.Collection" );<BR>oColl.items = selection; // selected items into collection</FONT></SPAN></DIV> <DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV> <DIV dir=ltr align=left><SPAN class=765042009-15062005><FONT face=Arial color=#0000ff size=2>// loop through the collection. No reason not to use a traditional integer loop for this but this is faster.</FONT></SPAN></DIV> <DIV dir=ltr align=left><SPAN class=765042009-15062005><FONT face=Arial color=#0000ff size=2>//<BR>for ( var f=new Enumerator( oColl ); !f.atEnd(); f.moveNext() ) {</FONT></SPAN></DIV> <DIV dir=ltr align=left><SPAN class=765042009-15062005><FONT face=Arial color=#0000ff size=2> var oItem = f.item();</FONT></SPAN></DIV> <DIV dir=ltr align=left><SPAN class=765042009-15062005> <FONT face=Arial color=#0000ff size=2>if ( oItem.type != "FileInputOp" ) {</FONT></SPAN></DIV> <DIV dir=ltr align=left><SPAN class=765042009-15062005><FONT face=Arial color=#0000ff size=2> removefromselection( oItem );</FONT></SPAN></DIV> <DIV dir=ltr align=left><SPAN class=765042009-15062005> <FONT face=Arial color=#0000ff size=2>}</FONT></SPAN></DIV> <DIV dir=ltr align=left><SPAN class=765042009-15062005><FONT face=Arial color=#0000ff size=2>}</FONT></SPAN></DIV><BR> <BLOCKQUOTE dir=ltr style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px"> <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left> <HR tabIndex=-1> <FONT face=Tahoma size=2><B>From:</B> owner-xsi@(protected) [mailto:owner-xsi@(protected)] <B>On Behalf Of </B>guillaume laforge<BR><B>Sent:</B> 15 June 2005 10:05<BR><B>To:</B> XSI@(protected)<BR><B>Subject:</B> FX tree : Select file input node only<BR></FONT><BR></DIV> <DIV></DIV> <DIV>Hi List,</DIV> <DIV><FONT size=2> <P>I need to select all the file input nodes from a fxtree. <BR>The script I write below seems to remove randomly some nodes ???<BR>I don't understand why ?</P> <P>//All the Fx tree nodes are selected.<BR>var oSel = Selection;<BR>for(i=0;i<oSel.count;i++)<BR>if(oSel(i).type != "FileInputOp")<BR>{<BR>RemoveFromSelection(oSel(i))<BR>}<BR>logmessage("only file input nodes are selected !") </P> <P>Any idea ?</P> <P>Cheers,</P> <P>Guillaume Laforge<BR>CG artist<BR><A href="http://www.vol2nuit.fr">www.vol2nuit.fr</A></P> <P> </P> <P> </P></FONT></DIV></BLOCKQUOTE></BODY></HTML>
|
|
 |