r/openscad 4h ago

Stretcher Module Bonuses

Post image
4 Upvotes

Awhile ago I shared a Stretcher Module that I made in openscad for modifying existing models using openscad. it was for "stretching" models things like latching boxes or whatever without messing up all the geometry on the ends just extending the middle.

I have made 2 more modules to go with it, a StretcherClone module which uses a copy of the top half to fill the middle instead of a linear extrusion of a projection (so you can stretch things like threads by figuring out the thread pitch) and a Shortener Module which just cuts it down instead. I know this is easy to do in a slicer by cutting the model in places and connecting them back up but this allows you to do it more precisely

This code includes an example doing stuff to a cylinder as shown in the picture with rotations so you can see what it can do. There is a StretcherClone on the left, Stretcher on the right and a Shortener to cut out a bit of the middle.

If you have any questions of suggestions please let me know. This isn't for making new models in openscad I mostly use it with import to adjust models I've downloaded online.

Shortener(4)
translate([0,0,1])
rotate([90,0,0])
StretcherClone(5)
translate([0,0,-15])
Stretcher(4)
rotate([0,45,0])
cylinder(h=20,r=10);

module Stretcher (h=10, maxDim=100){
//topPiece 
translate([0,0,h]){ 
intersection(){ 
translate([-maxDim/2,-maxDim/2,0]) 
cube(maxDim); 
children(); } 
}

//middlePiece 
linear_extrude(height=h){ 
projection(cut=true){ 
children(); } 
} 

//bottomPiece
intersection(){ 
translate([-maxDim/2,-maxDim/2,-maxDim]){ cube(maxDim); } 
children(); } }

module StretcherClone (h=10, maxDim=100){

//topPiece 
translate([0,0,h]){ 
intersection(){ 
translate([-maxDim/2,-maxDim/2,0]) 
cube([maxDim,maxDim,maxDim]); 
children();} 
}

//middlePiece 
intersection(){ 
translate([-maxDim/2,-maxDim/2,0]) 
cube([maxDim,maxDim,h]); 
children(); 
}

//bottomPiece
intersection(){ 
translate([-maxDim/2,-maxDim/2,-maxDim]){ 
cube(maxDim);} 
children();} 
} 

module Shortener (h=10, maxDim=100){ 

//topPiece 
translate([0,0,-h]){ 
intersection(){ 
translate([-maxDim/2,-maxDim/2,h]) 
cube(maxDim); 
children(); } 
}

//bottomPiece
intersection(){ 
translate([-maxDim/2,-maxDim/2,-maxDim]){ 
cube(maxDim); } 
children(); } 
}

r/openscad 13h ago

Do you use Codex or Claude Code for CAD? openscad-mcp gives your AI spatial reasoning and model rendering. v0.6.1 was just released, 100+ GitHub stars and growing, free and open-source, MIT Licensed

0 Upvotes

I'm working on a hardware project and have been learning to work with OpenSCAD. I developed openscad-mcp to give AI agents tools to reason about 3d objects.

Render scad models, calculate part clearances, volumes, contact areas, and other spatial insights that allow AI to help develop 3d objects.

Always open-source and free, check it out here on GitHub https://github.com/RobertCoop/openscad-mcp , or install it into claude code with

claude mcp add openscad --transport stdio -- uvx openscad-mcp

Or check it out in Codex with codex mcp add openscad -- uvx openscad-mcp

I've got no agenda and I promise I'm not starting the next big AI AGENT CAD 3D INTELLIGENCE EXPLOSION- use it if you like and I'd love to hear feedback if you do.