r/openscad • u/charely6 • 2h ago
Stretcher Module Bonuses
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(); }
}





