Lake House - for loop

   1553   6   2
User Avatar
Member
1 posts
Joined: Oct. 2017
Offline
I am new to Houdini (and coding for that matter) and I'm following the Lake House tutorial. She uses a for-loop subnet, which doesn't exist anymore in Houdini 16.5. I was wondering if anyone knows what I can use instead so that I can continue following this tutorial? Thanks!
User Avatar
Staff
1641 posts
Joined: March 2012
Offline
You can use the For Loop blocks. Depending on what sort of thing you're doing, there's “For-Each Connected Piece”, “For-Each Named Primitive”, “For-Each Number”, “For-Each Point”, “For-Each Primitive”, and “For-Loop with Feedback”. They set up a block to put operations in that acts similarly to the subnetwork, but all at the same network level, so that you don't have to keep diving in and out of the subnet. They also don't rely on stamping, so it's much easier to set up nested loops correctly.

There are a few examples around the forum showing various ways to use them; I don't know exactly which ones to point you to, since I don't know the specific scenario, but searching for for loop exampleshould hopefully find some.
User Avatar
Member
2 posts
Joined: Dec. 2013
Offline
I'm still a little confused on the new for each loop myself so I might be doing something wrong but will try and help and maybe better understand it myself by writing it here.

For that tutorial create a for each loop with the end block as iteration method "By Count“ and you are using ”Feedback Each Iteration“ Merge Each Iteration is like the old merge results checkbox.

Set the Block Begin Method to ”Fetch Feedback" and click the Create Meta Import Node. This Meta Input node is how you know which iteration you are in, in the for each loop and I will rename the node "nodename“ just to write something I can refer to later. The Metainput node is just a block begin with the Method set to ”Fetch Metadata" but clicking the button sets up the Block Path for you.

Plug the attribute create which in the tutorial should be labeled box_id into the “Block Begin”.

In the old tutorial you would often be using the stamp function with the for each loop now you are using that meta input node. Call the meta input node and the iteration the loop is in by writing detail(“../nodename”,“iteration”,0)


So in the old tutorial you would be calling the box id value stamp(“..”, “FORVALUE_stackboxes”, 0)+1 the new thing would be detail(“../nodename”,iteration",0)+1.
The locate node "@box_id==`stamp(“..”, “FORVALUE_stackboxes”, 0)`
would now be ”@box_id==`detail(“../nodename”,“iteration”,0)`" etc.




I hope that works enough to let you continue.

There are some other gotchas in newer Houdini and the move away from the stamp function. I think once anyone me included gets it, it will be a more direct, faster and easy to use method. For now it still trips me up if I am following something and I have to try and create it the old way look at it as I create it the new way.
Edited by Airlawn - Jan. 12, 2018 04:36:45

Attachments:
foreachloop.JPG (42.1 KB)

User Avatar
Member
2 posts
Joined: Dec. 2016
Offline
@Airlawn

Hello. I tried to do it your way and everything seems to work except one thing. Once I paste detail(“../nodename”,“iteration”,0) in the Seed value I get error in the origin box's Size parameter. That's what you put in the Seed value, right? Or I misunderstood?

(Error says “Unable to evaluate expression - Syntax error”, and it only happens when I change the Seed value)
User Avatar
Member
1 posts
Joined: Jan. 2018
Offline
SailorTwift
@Airlawn

Hello. I tried to do it your way and everything seems to work except one thing. Once I paste detail(“../nodename”,“iteration”,0) in the Seed value I get error in the origin box's Size parameter. That's what you put in the Seed value, right? Or I misunderstood?

(Error says “Unable to evaluate expression - Syntax error”, and it only happens when I change the Seed value)
I was getting this error too and I think it came from copy/pasting. I wrote it out myself and it worked

@Airlawns: @box_id==`detail(“../nodename”,“iteration”,0)`

Mine:
@box_id==`detail("../nodeName","iteration",0)`

Anyway, when it's correct your VEX will be colour coded. When it's not it will stay white so you know where the errors are (in this case almost certainly to do with however this forum is interpreting quotations).
User Avatar
Staff
1641 posts
Joined: March 2012
Offline
Yeah… because of the quote handling on the forum, I think support for the unusual quotation marks was added to VEX a few months ago, but I don't think it's been added to HScript. (When you use backtick expressions, it's evaluating HScript to find the string. The Group fields themselves don't use VEX or HScript, but rather a simplified syntax, unless you use the Group Expression node.)
Edited by ndickson - Feb. 4, 2018 23:59:17
User Avatar
Member
7 posts
Joined: June 2015
Offline
I've been following the same tutorial as an introduction to procedural building creation. I've followed your instructions which were great, it actually helped me understand the process a bit better, but I've ran into the problem where in video one part 2 where we create the balcony supports. Anastasia uses the foreach subnetwork node to replicate the process on every primitive that only has 2 direct neighbours. I'm having trouble recreating this work flow so that the number range on the old node is equal to the amount of primitives minus one (nprims(opinputpath(“.”, 1))-1).
Edited by Ben Read - Feb. 7, 2018 22:06:15

Attachments:
Selection_002.png (318.9 KB)

  • Quick Links