  | | | FX tree : Select file input node only | FX tree : Select file input node only 2005-06-15 - By Guillaume Laforge
Back When I write some scripts to learn I often use "XSI collection" but in a deadline I forget my new knowledge :-) Thanks kim !
2005/6/15, kim aldis <kim@(protected)>: > > 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 <http://www.vol2nuit.fr/> > >
<div>When I write some scripts to learn I often use "XSI collection" but in a deadline I forget my new knowledge :-)</div> <div>Thanks kim !</div> <div><br><br> </div> <div><span class="gmail_quote">2005/6/15, kim aldis <<a href="mailto:kim @(protected)">kim@(protected)</a>>:</span> <blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0 .8ex; BORDER-LEFT: #ccc 1px solid"> <div dir="ltr" align="left"><span><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><font face="Arial" color="#0000ff" size="2">< /font></span> </div> <div dir="ltr" align="left"><span><font face="Arial" color="#0000ff" size="2" >Try this:-</font></span></div> <div dir="ltr" align="left"><span><font face="Arial" color="#0000ff" size="2">< /font></span> </div> <div dir="ltr" align="left"><span><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><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><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><font face="Arial" color="#0000ff" size="2"> var oItem = f.item();</font></span></div> <div dir="ltr" align="left"><span> <font face="Arial" color=" #0000ff" size="2">if ( oItem.type != "FileInputOp" ) {</font></span>< /div> <div dir="ltr" align="left"><span><font face="Arial" color="#0000ff" size="2"> removefromselection( oItem );</font>< /span></div> <div dir="ltr" align="left"><span> <font face="Arial" color=" #0000ff" size="2">}</font></span></div> <div dir="ltr" align="left"><span><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 lang="en-us" dir="ltr" align="left"> <hr> <font face="Tahoma" size="2"><b>From:</b> <a onclick="return top.js.OpenExtLink (window,event,this)" href="mailto:owner-xsi@(protected)" target="_blank">owner -xsi@(protected)</a> [mailto:<a onclick="return top.js.OpenExtLink(window ,event,this)" href="mailto:owner-xsi@(protected)" target="_blank"> owner-xsi@(protected)</a>] <b>On Behalf Of </b>guillaume laforge<br><b>Sent:< /b> 15 June 2005 10:05<br><b>To:</b> <a onclick="return top.js.OpenExtLink (window,event,this)" href="mailto:XSI@(protected)" target="_blank"> XSI@(protected)</a><br><b>Subject:</b> FX tree : Select file input node only <br></font><br> </div> <div><span class="e" id="q_1047f547a1207bdc_1"> <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 onclick="return top.js.OpenExtLink (window,event,this)" href="http://www.vol2nuit.fr/" target="_blank">www.vol2nuit .fr</a></p> <p> </p> <p> </p></font></div></span></div></blockquote></blockquote></div><br>
|
|
 |