3D part design with OpenSCAD #85: Bending an .stl file.

A method to curve a flat stl file around a round object.

2 min read
By Bob
3D part design with OpenSCAD #85: Bending an .stl file.

The "bend" code also works with stl files, but a word of warning before you give it a try. I would not use an stl file that is larger than 20 Mb, I have and it still renders in about 2 1/2 minutes but it maxes out your cores and takes huge amounts of memory. If you don't have 32 gigs of ram and a decent graphics card it will probably crash as soon as it starts to load the file. Smaller files work much better but still take a bunch of ram.

Also it only works on files that are somewhat flat, when you try to bend something that is already curved it will crash.

Use this at your own risk.

here is the modified code:

/*[Bend STL]*/
Path_to_STL_File="/home/none3/Desktop/.stl";
bend=103.5;//[-360:.01:360]
tilt_angle=0;//[0:.01:180]
steps=5;//[3:1:200]
rotate_x=90;//[0:.01:360]
rotate_y=90;//[0:.01:360]
move_x=0;//[-400:.01:400]
move_y=0;//[-400:.01:400]
move_z=0;//[-400:.01:400]


/*[Clip Area]*/
show_clip_area=false;
clip_height=50;//[1:.1:400]
clip_width=100;//[5:.1:400]

dh=clip_width/steps;
r=clip_width/(bend*PI/180);
h0=-clip_width/2;render();


module bend_STL(){
render(convexity=3){ 
 translate([0,0,-r])
 rotate([bend/2,0,0])
for(i=[0:.7:steps]){
 rotate([-i*bend/steps,0,0])
 translate([0,-(dh*i+h0),r])
intersection() {
 rotate([0,0,90])
 rotate(a=tilt_angle,v=[0,0,90])
 import(Path_to_STL_File,convexity=10);
 translate([0,dh*i+h0,0]) 
 rotate(a=tilt_angle,v=[0,20,0])
 cube([clip_height,dh,clip_height],center=true);
 if(show_clip_area)
 translate([0,dh*i+h0,0]) 
 rotate([0,90,0])
 rotate(a=tilt_angle,v=[0,0,90])
 %cube([clip_height,dh,clip_height],center=true);
}}}}


rotate([rotate_x,rotate_y,0])
translate([move_z,move_x,move_y])
bend_STL();
open in new tab for larger image

    I will need to make some prints to see how a lithophane looks, but this should make it pretty easy to adapt a picture to pretty much any round object.