So, we are going to switch to the ForEach cycle in the Sobs context.
Perhaps you have already heard about ForEach cycles before, if you have experience in programming.
But in this case we will not use VEX or any other programming language,
because Houdini has a very useful version of the ForEach cycle that works in the Sobs context.
We will work with it.
To demonstrate the functionality of the ForEach cycle,
let's add a row of bricks along the top of this wall.
The first thing we need to do is, of course, add the CopyToPoints node.
And we need the same curve on the basis of which the wall is created.
Let me find the curve.
This one? Yes.
And we connect it here.
No, on the other side.
You may have noticed that I sometimes use this method.
I just press Y and draw a line like this to cut the connection.
And we need a brick.
Let's just take a box.
Let's check the size. It's too big.
Like this, for example.
If anything, the scale can be changed later.
And copy to the point.
Let's make it a little longer.
Great.
And I also want to add some facades on these bricks.
You can take PolyBevel.
Great.
And in the end we got such a row of bricks.
Let's combine everything again.
And so far they are lying on the ground.
We can connect from the position of this curve.
That is, the position of the curve is to be connected from the height of the wall.
I'll take the Transform node.
And PolyExtrude.
I'll copy the distance and add it here.
Great. Here they are, of course, intersect a little with a different geometry.
But it's okay. It will do for an example.
So, let's say we have such a geometry and we want to vary it a little.
We can also change the position of the curve.
For this, we would use the points that are on the curve.
We could change the position by Y.
That is, we just use what we created before.
But in most cases we may not have this copy to points.
With which we could work.
And in some cases it is even undesirable.
When we go to full setup, you will see examples of such situations.
Therefore, we need the ForEach cycle.
I will add the ForEach cycle.
And I want ForEachConnectedPiece.
Also, the Connectivity node is added immediately.
The Connectivity node creates an attribute.
By default, it is called Class.
It is used to determine what is connected to the mesh, and what is not.
This means that all these connected points will have their own ID.
If I open the table and find the class.
So, the first group up to 25, the class is equal to zero.
The second group up to 51, the class is equal to one.
And so on and so on.
That is, the first brick ID is one, the second is two, and so on.
It turns out that we have an ID that we can use in the cycle.
I turn on the last node.
And here we want to vary a little by Y.
Let's take the Transform node again.
Although it could be taken in Wrangler, but we will take Transform.
And we need access to each iteration.
If I turn on Single Pass, we will see that we have one iteration here.
That is, we are sorting each one in turn.
And to have access to this information, we need to create a metadata node.
By clicking on this button.
When we click, we get an additional node.
And here we see that we have some attributes.
Attributes are those that are stored on the object itself, not on each separate component.
We can check this in the data table.
Here on this tab.
Now there is an iteration.
And if I check different passes, we see that zero is zero.
Two, two.
And so on.
Now we have some information that we can use in the cycle.
This information can be used to change each associated object.
I will turn off Single Pass.
And now we can use these attributes.
Let me tell you how to write this.
This is what the expression will look like in the end.
Here we have a function, the detail function.
This means that we are looking for the attribute of the detail.
There are also expressions point, prim and vertex.
Depending on where the attribute is stored.
In this case, it is stored on the detail, so the detail function.
String is the node location.
The node is called IT.
And then the name of the attribute inside this node.
And at the end is the index.
Also note that there is no point marked here.
It is not needed when you write expressions in channels.
So, this is enough for now.
Let's go back to Houdini.
And so now we write here.
Detail.
Next, the path to the node.
We have not renamed it yet.
Now we do it in a second.
Next, the name of the attribute.
We see it here.
String float.
Surface node.
The name of the attribute.
Index attribute.
That is, we need the name iteration.
And index attribute.
It will not work until I rename it.
And then we write the same thing.
We need to call the node IT.
As you can see, it turns out the same effect as when using the number of points.
This is because in each iteration a different value is applied.
However, it does not work quite as we wanted.
We could do the same as before.
Use the fitrange function.
But instead, let's consider another way to do it.
Here I am quite satisfied with a fairly low value.
And I can, again, use the expression rent.
I can take this result.
And randomize in the range from zero to one.
Having already tried it, I realized that one is too big a number.
Therefore, here I also used the multiplier to reduce the value even more.
Let's see how it looks in the fitrange.
I will write rent.
And close.
And we get a random value for each brick.
This value is in the range from zero to one.
But we have already said that this is too big a value.
Let's multiply by 0.02.
We can change this value and in the same way we can connect it with some channel so that we have a slider.
Well, that's it. I think that's enough with cycles.
Let's put the network in order and at the end we will study different ways of exporting geometry.