Iterative division of rectangle

I would like to create this ‘algorithm’ in grasshopper using hoopSnake I guess…

It will take a rectangle and then divide it either horizontal or vertical, then it will take the newly created ‘rectangles’ and do it again until at a minimum size is reached… I hope somebody can help me to figure out how to do this. I have tried, but without succes.


DivisionOfRectangles.gh (22.3 KB)

Why not using Substrate component ?

Completely different result though.

Why iterative?


div_rectangle_2020Sep12a.gh (6.7 KB)

P.S. Oh, I see - random. Why require Heteroptera for that? Your Geo is not internalized.

missing
missing2

I don’t believe this is as well behaved as I would like, but it’s not too bad? Anemone, not HoopSnake.


div_rectangle_2020Sep12b.gh (26.6 KB)

P.S. Here’s the effect of increasing the range/value of the ‘Repeat’ slider and decreasing the ‘size’ slider.

2 Likes

Try this and improve it, you need Anemone loop and a python component (attached).

rec.gh (21.4 KB)

Brep Borders.ghpy (23 KB)

There’s also some examples of this on the old forum. Here’s a GHPython solution I did:

1 Like

Thanks first of all.

The problems is that the big blue area is not divided while the other areas are really small.


This is a manual example of how it should end up looking like…


And this is an example of piece of furniture I build where I manually created the grid… This is what this solution should be used for, to give some context. Don’t mind the ‘gap’ with the lamp on the floor, it would be nice if it could work just from a rectangle, and end up with vertical and horizontal lines.

I matched your input values (white group) as best I could but you removed the ‘0 to 300’ domain for the Random component so I don’t know what domain you are using for that? Or what other changes you may have made to my code? (I don’t read icons very well.)

The big blue area is probably because you need to increase the range/value of the ‘Repeat’ slider?

As to being too small, yes, that’s a problem caused by using area to measure minimum size instead of length of shortest side. I’ll take another look at that.

As always though, when you modify code, you own it.

This version is much better. The ‘minSize’ slider specifies the minimum length of either edge (horizontal or vertical) of the resulting boxes. Please explore all of the parameter inputs (white group) except for the ‘0 to 300’ domain before making any changes to the code.


div_rectangle_2020Sep13a.gh (41.5 KB)

P.S. I left some tools on the canvas in the previous version, not shown in the image. This is only the iterative division code.
div_rectangle_2020Sep13a2.gh (16.5 KB)

A key feature to making this work is the sFace (Shrink Faces) component, a single line of C# code, used twice.

B.Faces.ShrinkFaces();

1 Like

Looks brilliant. Will check it out when I come in contact with some prober metal. :slight_smile:

This was exactly what I was searching for… The only thing which I will have to change is that it will export lines instead of rectangles… I can do that with the ‘Typologizer’ plugin. Maybe you have a better solution?

Otherwise you answered my question so nice. :slight_smile: It even works with polylines as input instead of rectangles.

You don’t need a plugin to get the edges of surfaces, just run the surfaces through a Crv param:

I hadn’t thought of that, will check it out.

But I will get edges on top of each other if I do it like that. I need unique lines only.

Well, that’s a problem isn’t it, since many of them overlap. Let us know how you solve it.

For what it’s worth, here’s a way to separate horizontal lines from vertical lines:

I think I got it. The yellow group at first appears to do the trick but those are “dirty polylines” that double back on themselves with overlapping segments. The orange group fixes them by using Discontinuity to get visually accurate end points and recreating each line.

Curve End Points were useless for this task because they were usually somewhere in the middle of the dirty polylines. I tried various ways to find the pair most distant from each other and stumbled on Discontinuity for that job. Not quite sure why it works…? :thinking:


div_rectangle_2020Sep14a.gh (33.4 KB)

I can generate this so I think it does :slight_smile:

This is generated from 3 rectangles.

You can check the result if you like:
rectangleGenerator.3dm (17.9 MB)

There are still problems due to material thickness, when two elements are within materialthickness from one and other it will not work in the real world…

But very nice work from your side. :slight_smile:

If not for the removal of a few edges (3?) here and there, wouldn’t it be easier to use the rectangles from Loop End to build a bunch of boxes and glue them all together? Trim pieces around the outside edges would match their thickness to that of the adjacent boxes. What provides shear strength?

A bracket attatched to the wall… :slight_smile: There is a light switch there so we have to do it like that.

See this related thread suggesting “Topologizer” for this problem: