Blender 3.0 - Geometry Nodes - Replace an instance object according to conditions (if else)

I try to use geometry nodes to generate a procedural building (Width, Length, Height, random distribution (Windows, doors, balcony etc...)). With some tutorials, I am pretty happy with the result but i would like to add some balconies with conditions in order to link them together when they are on adjoining cells.

I used the grid node and instance on points node to generate the different faces of the building from different type of "cell" (of 3 meters height by 3 meters width).

When two balconies are side by side, i would like to replace them by another type to join them. To do this, I have decided to put in my instance collection just one type of balcony (Type A) and if it's next to another, I would like to change the instance object by another according to some conditions.

To sum up:

• Instance object to replace: n
• Instance object to the left of n: n-1
• Instance object to the right of n: n+1
• Istance collection of every balcony: Ac
• Standard balcony: A
• Left balcony: B
• Middle balcony: C
• Right balcony: D

If n = A:

• If n-1 and n+1 are Ac
• Then n = C
• If n-1 = Ac and n+1 =/= Ac
• Then n = D
• If n-1 =/= Ac and n+1 = Ac
• Then n = B
• Else n = A

Else n doesn't change.

I tried to use the different attribute nodes, but I have to admit that I don't really understand even with the blender 3.0 manual.

So first of all, I would like to know how i can get the instance objects (type Balcony A for example) from the final instance list (every instance objects that constitute the wall), and then how i can replace it. Finally I would like to know if it is possible to make a if/else condition. Maybe I can do this with the compare floats node, to compare the x and y position from every instances object?

I hope it will be clear for you, and you can help me!

Thank you for those who will try to find an answer or some tips! :)

• I made huge upgrade of my answer. Don't miss it. Commented Feb 13, 2022 at 13:08
• Finally I even succesfully downgroud my solution for blender 3.0. You can download the file. :) Commented Feb 13, 2022 at 23:25
• @3Dhedgehog Thank you very much! I thought I would get just some advice about some geometry nodes to use! Wow! I hope it did not take too long! You even make a downgrade! I will check each solution to understand the logic behind and test that tonight! Thank you very much again!! Commented Feb 14, 2022 at 11:55
• Yep, I know that I have done your job instead of you. :) And probably I should not did so. In total it took about nine hours. But lucky for you I had a lot of free time this weekend. Also your question was absolutely beautiful, well asked, challenging and very interesting. Not so much really interesting questions here. I prefer to give attention to one challenging question instead of answering several boring. Commented Feb 14, 2022 at 13:37

You can move points (instances) in each wall to one step right (or left). If you compare distance between original points (instances) and moved points (instances) then you can select points (instances) with equal positions and delete or replace them.

My first solution (For Blender 3.1):

...inspired by beer... But I will not remove it because it works and could be helpful for someone.

Fun:

All setup:

Here you can see a kind of cascade. It replace basic balconies with doublewidth balconies. It replace doublewidth balconies with triplewidth balconies. And so on.

Inside "Replace" Group:

"Replace" Group is the key of this solution. It compare positions of original points (instances) with offset points (instances). If positions are equal, it delete two original instances and replace them with one new point.

Inside "Cute Balcony" Group:

I build "Cute Balcony" group just for fun. Of course you can use any other geometry instead of it. But for me it was very helpful to have procedural balcony generator, that can make balconies of different width.

File to play with (Blender 3.1):

:)

Better solution (For Blender 3.1):

This is exactly what you ask for. At night I understand that your question is more wise then my first answer. Because in my first solution I have to build endless cascade, if I want to make it work without bugs at building of any size. So I decide to make better version, where balconies have side and middle parts.

Fun:

It became much more complex. But principle of operation is the same. It compare itself with right points (instances). Delete. Replace. It compare itself with left points (instances). Delete. Replace. It compare results of previous two operations, and if they are equal it replace them with middle block.

Prebuilds for balcony:

File to play with (Blender 3.1):

=)

Final Edit. Doungrade for blender 3.0:

I was curious if it is possible to do all of that in blender 3.0. And yes! Here is successful downgrade.

File to play with (Blender 3.0):

:)

• What method are you using to manage noodle? Are you using any add-on or doing it all manually? Commented Feb 13, 2022 at 13:58
• @G_Basak Manually with hotkeys. Shift+Tab enable snap. Shift+RMB create new reroute. Cntrl+RMB remove connect. It is very fast and accurate way to work with nodes. Commented Feb 13, 2022 at 15:25