Constraining cylinders within complex geometry

Hi all,

Hoping someone here will be able to help me with this. I’m not too familiar with all the possibilies in Grasshopper and have tried to approach this with a python script but haven’t had any luck so far. I’ve also spent the last hour scouring the internet and YouTube but haven’t found anything useful, pardon if this is a novice question.

Essentially, I have sets of closed polysurfaces which make up a structure, but I need this structure to be made of vertical cylinders instead. I’d like to create a script which takes an array of cylinders and adjusts their heights to be constrained within the closed polysurfaces - I’m choosing to do this over a trim or split as I would like the cylinders to remain XY flat on both ends, if that makes sense.

My file is attached, I internalized the data but please let me know if anything is missing.

Thank you!!

cylinders_GPT.gh (1.5 MB)

Hello
here is a way with Mesh Ray, the idea is to make a bounding box, so calculate the extend of the geometries, then make a grid with Diameter of tube, then use this grid to make points on the top and bottom of geometry, throw some ray toward the geometry and if intersection draw a line that will be used to make cylinders

Mesh is used here as it could be joined easily.
There is also a component for Brep but I didn’t find a more simple way to use it.
cylinders_still_human_answering_LD.gh (1.5 MB)

Thank you!

This solves my issue perfectly, and thank you for providing the file - I’ll go dissect it now and learn how these nodes piece together. Your way of thinking makes a lot more sense than what I originally imagined.