Or stop messing around with cross-language data type conversions and
use Python :-D
for i in range( len(
Application.selection(0).subcomponent.elementarray ) ):
Application.logmessage(
Application.selection(0).subcomponent.elementarray[i] )
(this has to be run in one line)
Cheers
Bernard
On 4/20/06, John Bell <jbell(at)massrender.com> wrote:
> Got it, thanks for the assist.
>
> ====Begin Code====
> // Create a new array of selected components (VB array)
> var vbaEdges = new VBArray( Selection(0).subcomponent.elementarray );
>
> // Convert to JS Array
> var jsaEdges = vbaEdges.toArray();
>
> x = 0
> for ( cEdge in jsaEdges ) {
> logmessage(jsaEdges[x]);
> x++
> }
> ====End Code====
>
>
> ===Begin Output====
> //INFO : 9,10,17,24,31,38,45,52
> //INFO : 9
> //INFO : 10
> //INFO : 17
> //INFO : 24
> //INFO : 31
> //INFO : 38
> //INFO : 45
> //INFO : 52
> ====End Output====
>
>
>
> Stephen Blair wrote:
> > Take a look at the example on the ref page for PickElement.
> > The "trick" is that the ElementArray returns a Visual Basic safe array
> > that has to be converted to a JScript array.
> >
> > -----Original Message-----
> > From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf
> > Of John Bell
> > Sent: April 20, 2006 9:56 AM
> > To: XSI(at)Softimage.COM
> > Subject: Re: Loop through a component selection (scripting)
> >
> > Thanks Andy. That look exactly like what I want to accomplish. I will
> > try it shortly. Could someone demonstrate how it could be done with
> > elementarray? I was trying to use it but I couldn't get it to happen -
> > still trying to rap my head around some concepts of object oriented
> > programming.
> >
> > Thanks!
> >
> > Andy Nicholas wrote:
> >
> >> Hi John,
> >>
> >> I think you probably want this:
> >>
> >> var selected_edges = Selection(0).subcomponent.componentcollection;
> >> var num_sel_edges = selected_edges.count;
> >>
> >> for(var i=0;i<num_sel_edges;++i)
> >> {
> >> var cur_edge = selected_edges(i);
> >> ...
> >> ...
> >> ...etc.
> >> }
> >>
> >> Alternatively, you can use subcomponent.elementarray to get the array
> >> of edge indices.
> >>
> >> Cheers
> >>
> >> Andy
> >>
> >>
> >> -----Original Message-----
> >> From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On
> >> Behalf Of John Bell
> >> Sent: 20 April 2006 05:20
> >> To: XSI(at)Softimage.COM
> >> Subject: Loop through a component selection (scripting)
> >>
> >> I am trying to write script that can loop through a selection of
> >> components with a for...in loop.
> >>
> >> I created a sphere and then selected some of the edges on it.
> >>
> >> selectedEdges = Selection(0);
> >> logmessage(selectedEdges);
> >>
> >> This yields:
> >>
> >> //INFO : sphere.edge[5,16,35,46,59,69,83,92,107,115,131,138]
> >>
> >>
> >> So my edges are selected, but how do I get so that I can run through a
> >>
> >
> >
> >> for..in loop that effects the next edge in the list as the loop is
> >> reiterated? I have tried messing with SubComponent properties, and
> >> other objects to see if I could store the list as an arrays, but I
> >> have not had success. What am I missing?
> >>
> >> Thanks.
> >> ---
> >> Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in
> >>
> > body:
> >
> >> unsubscribe xsi
> >>
> >>
> >> ---
> >> Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in
> >>
> > body:
> >
> >> unsubscribe xsi
> >>
> >>
> > ---
> > Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in
> > body:
> > unsubscribe xsi
> >
> > ---
> > Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
> > unsubscribe xsi
> >
> ---
> Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
> unsubscribe xsi
>
---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi