<p>OpenSCAD lacks any facilities to perform computations on the resulting geometry (derived from CSG or directly imported). It has a decent functional language for expressing geometry in terms of parameters and functions/modules, but the road is one way; geometry is an output only and doesn't loop back into input. So automation of this entirely in OpenSCAD is really not an option.</p>
<p>On the other hand, doing it manually is rather easy. You can use CSG operations (intersection or difference) to cut the model, cut a compartment out of it, cut threads in it, etc. as well as (union) attaching external threads. You just have to decide how to size and position them for your model yourself.</p>
<p>Note that there's no canonical module for doing threads in OpenSCAD. You can either derive the cross section for your thread profile (can be done with OpenSCAD code) then <code>linear_extrude</code> it with twist (needs really fine division to be accurate though) or skin a <code>polyhedron</code> for the thread. There are a few published modules for the latter and I have an unpublished one I prefer.</p>

CC BY-SA 4.0
2020-07-12T19:26:25.037Z
Perfect answer!
Do you know any simple way to create that simple streamlined process for converting solid .stl models into having a let's say secret compartment within them?
Could csg.js be a viable option maybe?
zerz
CC BY-SA 4.0
2020-07-12T19:56:57.377Z
You may be able to get OpenSCAD to output the CSG AST and process that with external tools, or just output the STL file (probably easier) and process it to make decisions about where to put cuts, etc.
R.. GitHub STOP HELPING ICE
CC BY-SA 4.0
2020-07-12T20:47:00.387Z
Alright. I'm thinking along the lines of creating a simple web-form where solid model files can be uploaded and automatically get overhauled so there's a module of choice that fits perfectly inside of it when 3D-printed. 

Currently looking into [ported OpenSCAD libraries for OpenJSCAD](https://www.thingiverse.com/thing:2307544), seems promising but I'm not that experienced in this field just yet so I'd love any clues to help put it together.
zerz
CC BY-SA 4.0
2020-07-12T19:09:14.933Z
2020-07-12T19:09:14.933Z
R.. GitHub STOP HELPING ICE
<p>I had a thought the other day that it's 100 % waste to have either a solid or hollow 3D-printed model in relation to utilizing the space inside of it for different modules, e.g. secret compartments, modules like salt/pepper shakers, etc.</p>
<p>So I thought the best way of achieving this in a streamlined semi-automated manner is creating a simple script in OpenSCAD / FreeCAD and I would love some professional input on how to achieve this exact process:</p>
<ol>
<li><p>Split any given model at X height with Y angle Z times (eg. slicing a model in half &amp; keeping both parts separate)</p>
</li>
<li><p>Make a hollow compartment inside the model with working 3D-printable threads sticking out from one part fitting into the other with definable shape, tolerance &amp; size in relation to the parts size (eg. a cylindrical hidden compartment or a space where specific user-made modules fits into)</p>
</li>
</ol>
<p>I'm thinking a few simple yet potent lines of OpenSCAD code or a FreeCAD script should do the trick but my knowledge is limited in this field at the moment so any input is highly appreciated.</p>

<3d-design><openscad><freecad>
OpenSCAD / FreeCAD splitting, hollowing and threading model
zerz
# OpenSCAD / FreeCAD splitting, hollowing and threading model

(Asked by: username_0 on 2020-07-12)

I had a thought the other day that it's 100 % waste to have either a solid or hollow 3D-printed model in relation to utilizing the space inside of it for different modules, e.g. secret compartments, modules like salt/pepper shakers, etc.

So I thought the best way of achieving this in a streamlined semi-automated manner is creating a simple script in OpenSCAD / FreeCAD and I would love some professional input on how to achieve this exact process:

1. Split any given model at X height with Y angle Z times (eg. slicing a model in half & keeping both parts separate)
2. Make a hollow compartment inside the model with working 3D-printable threads sticking out from one part fitting into the other with definable shape, tolerance & size in relation to the parts size (eg. a cylindrical hidden compartment or a space where specific user-made modules fits into)

I'm thinking a few simple yet potent lines of OpenSCAD code or a FreeCAD script should do the trick but my knowledge is limited in this field at the moment so any input is highly appreciated.

**Tags:** 3d-design, openscad, freecad

---

## 1 answers

### Answer by username_1 on 2020-07-12. Score: 2

OpenSCAD lacks any facilities to perform computations on the resulting geometry (derived from CSG or directly imported). It has a decent functional language for expressing geometry in terms of parameters and functions/modules, but the road is one way; geometry is an output only and doesn't loop back into input. So automation of this entirely in OpenSCAD is really not an option.

On the other hand, doing it manually is rather easy. You can use CSG operations (intersection or difference) to cut the model, cut a compartment out of it, cut threads in it, etc. as well as (union) attaching external threads. You just have to decide how to size and position them for your model yourself.

Note that there's no canonical module for doing threads in OpenSCAD. You can either derive the cross section for your thread profile (can be done with OpenSCAD code) then `linear_extrude` it with twist (needs really fine division to be accurate though) or skin a `polyhedron` for the thread. There are a few published modules for the latter and I have an unpublished one I prefer.

> **Comments:**
> **username_0**: Perfect answer! Do you know any simple way to create that simple streamlined process for converting solid .stl models into having a let's say secret compartment within them? Could csg.js be a viable option maybe?  
> **username_1**: You may be able to get OpenSCAD to output the CSG AST and process that with external tools, or just output the STL file (probably easier) and process it to make decisions about where to put cuts, etc.  
> **username_0**: Alright. I'm thinking along the lines of creating a simple web-form where solid model files can be uploaded and automatically get overhauled so there's a module of choice that fits perfectly inside of it when 3D-printed.   Currently looking into [ported OpenSCAD libraries for OpenJSCAD](https://www.thingiverse.com/thing:2307544), seems promising but I'm not that experienced in this field just yet so I'd love any clues to help put it together.  

---

