How can GH find the maximum incircles in an irregular area?

Hello everyone,

Here I have an irregular shape as attached. I want to find the maximum incircles for each semi-closed part (I should find four incircles according to the shape) using GH, otherwise I have draw them one by one manually.
Any suggestin and help is so appreciated!
incircles.3dm (77.5 KB) (21.7 KB)

Here’s one approach, using the medial axis.
(it uses this extra component Topologizer.gha (19 KB) )


Hi Daniel,

That’s so cool!! Thank you so much for your kind and prompt help!
I am trying it now.

I tested the code, and it has so smart idea using voronoi component, and the Topologizer is a fantastic tool!
Now I try to add some code to select the maximum incircle for each section. My idea is to group the incircles by testing if they are intersecting, then choose the maximum incircle in each group.
Do you have any other suggestion, Daniel?
Thanks again!

Hi Daniel,

Thanks again for your nice code. Here I have a new problem. Now there are multiple curves (e.g., two curves), and I want to create the incircles for them in one time, instead of selecting the curve and creating the incircles one by one. However, when two curves are selected, the code can’t work well, as the pic shows. I know there must be some setting for the data tree structure, but it’s really beyond me. Could you please help me solve the problem? Thank you so much! (40.3 KB)


There were a couple of changes required in the definition in order to make it work with multiple curves.

First, do not simplify unless you know very well what you are doing and that you know for sure your inputs won’t change. Here for example, you changed from 1 curve to 2 curves, so by simplifying you crippled the definition’s ability to adapt.

Instead, always use Shift Path

@andheum puts it quite eloquently:

Rule 04:

No Simplify! It makes things look nicer but believe it or not those zeros are meaningful and shouldn’t just be eliminated. If you are OCD about the way your paths look, then Path shift after every operation that introduces a new branch level (a new “0” at the end) IF AND ONLY IF you are sure that in the case of your definition the component will always function “1 to 1” - that is, for every single input there is only one output.

Apart from that, Daniel’s @DanielPiker custom component seems to have trouble handling multiple branches at least for the N output. (Maybe my component version is outdated, I did not bother to download the latest provided in this thread). So I had to use another approach using the G output instead.

I noted the changes in groups. And added Param Viewers so that you could follow the data structure along the way ( you can delete those if you want). Lastly, I could not help but tidy up the definition according to personal preference, I am sorry for that. (37.8 KB)

1 Like

Thank you so much, ShynnSup, for your nice code and detailed explanation!!
That’s really what I want, although I still don’t understand well the function of “shift”, and I need do some test by myself for it.
Thank you also for the suggestion on the “simplify”, I will follow that carefully.
Have a nice day!

I really like the Topologizer!

Is it something new?

Here I got the idea of “shift” from the post of

Yes, basically it goes back one step(or the number you specify) in your data structure.

Take for example this simple definition that creates a circle, divides it in points, uses those points to split the circle into segments and then divides those segments into points again.

You can see how the data structure becomes more complex with each step:
Shift Path allows you to “go back” one or many steps.
See for example the last part and compare step 3) with step 5) (one step for each Param Viewever)

  • On step 4) You have 4 segments, and each of these segments contains 5 points.
  • Before this on step 3) , we only had 4 segments, all in 1 list.
  • When we use Shift Path on the last step 5) , we go back to having 1 list. But in this case is a list of 20 points. Why 20? Remember we had 4 segments and 5 points per segments 4 x 5 = 20.

So in conclusion: Step 3) = Step 5) in terms of data structure.

So, important note: “Going back” does not mean you will have the same geometry. We are only talking about data structure, you go back to the same data structure, but you now have Points instead of Circle segments.

Now instead of 1 circle consider 2 circles (don’t worry for 3, 4, …100 circles it is the same as with 2 :wink:)

Experiment and try it yourself:
shift path (18.8 KB)


That’s a great explanation, ShynnSup! You work is always so clear and clean, like an art!!
I will study carefully your words and try the file you provide.
Thanks again for your efforts and kind help!