Jump to content

About the (wonderful) ForLoop SOP


David Gary

Recommended Posts

Hey Simon!

Very very useful HDA! I've understand how it works, it's very simple!

Congratulations! :) :) :)

A suggestion:

Why not use an internal variable (incrementing at each loop), that could be used through expressions within the SOPs that are between forloop and forloopend ( analoguous to the features of a copy SOP) ?

It's just a little more code to write ( declare and increment a variable in your calback command, two more lines...).

I see many applications for that. It is soon going to be a universal HDA!

Link to comment
Share on other sites

Yeah, a loop counter variable would be very useful. Here's my changes attached. The OTL is already embedded. You'll have to copy it out using the Operator Type Manager if you want to re-use it. I won't bother until I see what you guys think.

PS. I think I also fixed an off by one bug in it as well.

forloop.zip

Link to comment
Share on other sites

With a SwitchSOP which is equivalent to a switch/if-else statement (SwitchSOP with NullSOP for if), a ForLoop SOP, Houdini becomes more procedural than ever. I like it!

We've got almost all the programming structures in the modeling process. It could be generalized to COP and CHOP...

I'm going to do some fractal art with all that! And completely generalized L-Systems.

Link to comment
Share on other sites

Feel free to amend it at will, i'll add the suggested variable. The only reason I left it out was because I felt it was more efficient to use attributes that increment rather than global variables, these can be added "inside" the loop. That way it is stored with the geometry. Also, when you increment a variable sometimes you need to use varchange to get it to recook and that can slow things up a bit. Anyway I'll put it as an option.

You're right about the off by one bug, wasn't really something I checked :rolleyes: it was more the fact that it could be done so simply with an hda that i was impressed with. All it really needs is now is an "on cook" event so that it can be triggered without any user intervention. I've RFE'd it with Sesi, but if you think it is useful write to them and RFE it too, that way it is more likely to happen. Of course they might even create a proper subnet to do it with all the bells and whistles you can think of.. :P

Link to comment
Share on other sites

Yeah, that's how I added the variable. It's a detail attribute called "loopcnt" that has a variable mapping to LOOPCNT. So if you look at the hip file I posted, it simply uses $LOOPCNT to create the point group by expression. It would have helped if I could have used it directly in a Group field but that would probably require creating something that param() could use (like in a real loop sop) which isn't possible(?).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...