For loop question

Discussions about SOFTIMAGEs© Interactive Creative Environment©
Post Reply
User avatar
Daniel Brassard
Posts: 878
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario
Contact:

For loop question

Post by Daniel Brassard » 18 May 2011, 04:57

Hello ICE Gurus,

I have this piece of ICE tree that need to repeat based on an integer value input. It repeat between the add node and the scalar to vector node, with each iteration feeding a value to an array. In code that would be easy:

Code: Select all

var u = 4;
var x = -.05;
for (i=1, i <= u-1, i++) {
x = x + 1/u ;
}
I must admit my brain is fried from the lack of sleep. How do you change the ICE tree to correspond to the for loop?

Thank you for your help!
Attachments
For_loop.jpg
For_loop.jpg (53.21 KiB) Viewed 1955 times
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Hirazi Blue
Administrator
Posts: 5107
Joined: 04 Jun 2009, 12:15

Re: For loop question

Post by Hirazi Blue » 18 May 2011, 09:21

I'd look into the "Repeat" or the "Repeat with Counter" compound,
and the "While" or "While with Counter" compound,
The "with Counter" variants give access to the counter itself, obviously,
if you plan/need to use it in your tree...

But I'm no ICE Guru myself, :-o
so there probably are better solutions...
;)
Stay safe, sane & healthy!

User avatar
Memag
Posts: 339
Joined: 09 Aug 2010, 01:37
Location: Tits

Re: For loop question

Post by Memag » 18 May 2011, 10:08

No guru here, but this might help.

User guides
Looping: While and Repeat
The While and Repeat nodes can be used to “loop” or repeat a branch of a tree.
If the Condition of a While node has been filtered out for a given member of a data set, then no processing is done for that element. Similarly, if the Iterations of a repeat node have been filtered out, no processing is done for that element.
If you need to get the iteration number within the loop, store it in a custom attribute.

Area thread
hello Ron,
just take a look into the “Constrain Strand Length” compound. Within this compound you can find another compound “Iterate over Strand Fixing Segment Lengths"->"Iterate on Array”. This is a good example how loops with an iterator can be realized within ICE.
Best regards,
chris

Check out these posts as well,

Repeat Loops And Redundant Attribute Declaration

Polygon Islands : Using Arrays


Hope some of it helps.

User avatar
xsisupport
Posts: 713
Joined: 09 Jun 2009, 11:02
Location: Montreal Canada
Contact:

Re: For loop question

Post by xsisupport » 18 May 2011, 11:59

The alternative to a loop is to build an array of the values (in general, preferred over huge loops). Depends on the rest of your tree whether you could use this array.
Image
// Steve Blair
// "You're not a runner, you're just a guy who runs" -- my wife
//
// My Blogs: Arnold | Softimage

User avatar
xsisupport
Posts: 713
Joined: 09 Jun 2009, 11:02
Location: Montreal Canada
Contact:

Re: For loop question

Post by xsisupport » 18 May 2011, 12:11

For loop version
Image
// Steve Blair
// "You're not a runner, you're just a guy who runs" -- my wife
//
// My Blogs: Arnold | Softimage

User avatar
Daniel Brassard
Posts: 878
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario
Contact:

Re: For loop question

Post by Daniel Brassard » 18 May 2011, 14:13

Wow, that was quick. Thanks everyone for your replies.

I did look at the repeat, repeat with counter, while and while with counter, unfortunately all have an execute output port which is incompatible with the slice and keep polygons node which take an array as input.

It look like the array solution from xsisupport is the way to go.

Other solutions are worth noting (iterate on array, polygon islands: using arrays from Guillaume Laforge blog, etc). Thanks for the links, I will definitively investigate them all, these tricks are going to be useful in a near future.

On to the drawing board. Maybe a topology compound coming soon!

Cheers!
$ifndef "Softimage"
set "Softimage" "true"
$endif

User avatar
Daniel Brassard
Posts: 878
Joined: 18 Mar 2010, 23:38
Location: St. Thomas, Ontario
Contact:

Re: For loop question

Post by Daniel Brassard » 19 May 2011, 04:21

Excellent! The array method work very well and allowed me to eliminate some nodes.

EDIT

I have uploaded two compounds in the ICE Compound area: DB_Cube_V1 and DB_Cube_V1a

Hope you like it!

Cheers!

Dan
$ifndef "Softimage"
set "Softimage" "true"
$endif

Post Reply

Who is online

Users browsing this forum: No registered users and 34 guests