I am modelling a few cut templates to be used on an hexagonal grid (honeycomb) material using OpenSCAD. Basically, from a reference cell, I need to select all cells that are within a given range and given angle.
I implemented this by creating an in memory grid that covers an area larger than what I need (extra range, 360 degrees), and then testing each cell for both the distance and angle requirements, extruding only those that test positive for both conditions.
Everything works as expected...
...but now I would also like to add the possibility to have the outer contour of the template without having each individual cell within it (so, a single thin line going around the whole "pizza slice" above).
I'm pretty new to OpenSCAD: what would be the best approach here? (I'm happy even with a solution that requires to re-implement what done until now).
Unfortunately, OpenSCAD does not have a 2D hull() transformation, although it has been requested. You might be able to find a pre-written package that implements a 2D hull. However, if all you want is a hexagonal grid with a border of some arbitrary shape, could you not cheat, and get your slicer to generate the grid for you? All you would need to do is generate the envelope, and then slice with a hexagonal grid as in-fill, and request no top or bottom layers. Most slicers will do hexagonal in-fill.
If you want to do it all in OpenSCAD, then I would go about it like this:
- Create a 2D grid, similar to what you have now.
- Create a 2D outline of the shape you want, undersized so that you can add a manifold (as a perimeter).
- Duplicate this shape.
- Add a manifold to the first copy.
- Create an intersection of the second copy and the grid.
- Create a union of the two copies.
- Extrude the union.