Houdini Resources

Updated on Sept 1  2022


copyright © Deborah R. Fowler

Wrangle Node Examples

Deborah R. Fowler



Wrangle Node Example - Window Calculation

Posted on April 13  2020


This example uses a wrangle node to calculate the number of windows in a given space with an evenly spaced gap. It is similar to the python exercise in 160 but now with a point wrangle node to do the calculation. Tags: delete node, copy to points, point wrangle in detail mode

sideDoor.hipnc (created in H18)

The wrangle node is commented but I want to give you the overall process.

Here I am going to describe the last solution in the hipnc. There are many ways to position windows and doors and other example files are on my website but if you love wrangle nodes (or even if you don't) this is a great way to have a door and windows equally spaced on your building.

MISSING IMAGE

We first have our door, windowSize and over size of the wall we are trying to put them on (in this case it is ch("../width") but you could imagine this being done in depth. If you were to do it in depth you would use the depth parameter and then remember to change xval to zval.

The spaceForWindows is simply taking the overall size and subtracting the door and spacing. Spacing can be set to zero, if the width divided perfectly by the parts there would be no space so this parameter allows the user to increase the spacing if desired.

winFit is calculated how many windows can potentially fit into this space (given the door takes up some room too - already taken into account above.
geoFit has to do with how we are calculating the gap - more on that in a moment.

Now that we have some idea of how many windows can fit (winFit) we are calculate how much space is leftover. So if the windows were all smushed beside each other along with the door that is how much those physically objects take up but how you want to know what space is leftover. We then can divide the leftover by the number of spaces we need. For example if normally we had 5 windows we would have 6 spaces, however we also have a door so that means 7 spaces.

MISSING IMAGE

So we define geoFit = winFit + 2
We take the leftover space and divide by the number of gaps we need. That gives us our gap size.
Moving to the left (start = -size * .5), we place the windows after the gap on the left and the door and then proceed across. (160s - remember the quilt exercise).
With point wrangle we add a point for each of those calculated locations (loop is for all the windows).

Finally, we create a point for the door. Done!

We then use a delete node and copy to points.
MISSING IMAGE

The other nodes in the file are other methods but hopefully this makes the problem solving process clear.