Creating Stairs With Openscad

Discussion in 'Software and Applications' started by stonysmith, Jul 24, 2018.

  1. stonysmith
    stonysmith Well-Known Member Moderator
    OpenSCAD (http://www.openscad.org) is a free parametric modeller.. you "code" the designs rather than "drawing" them with your mouse.

    A recent question came up about how to design a set of stairs around a curved surface.

    This code will do the job:
    Code:
    thinwall=0.3;  //minimum thickness for material FUD=0.3 WSF=0.7
    height=20; //height of the tank
    radius=20; //radius of the tank
    rise=0.75;run=1;width=3; //size of each step
    
    steps=height/rise;echo("steps=",steps);
    x=(radius+width/2)*2*PI;
    angle=360*((steps*run)/x)/steps;echo("angle=",angle);
    
    color([1,1,1,1])cylinder(r=radius,h=height,$fn=64);
    for (i=[1:steps]){
        rotate([0,0,i*angle])translate([radius+width/2,0,i*rise])cube([width+.1,run,thinwall],center=true);
     
        hull(){//outer curve between steps
            rotate([0,0,i*angle])translate([radius+width,0,i*rise])cube([thinwall,run,thinwall],center=true);
            rotate([0,0,(i-1)*angle])translate([radius+width,0,(i-1)*rise])cube([thinwall,run,thinwall],center=true);
        }
    
        hull() {//handrail
        rotate([0,0,i*angle])translate([radius+width,0,i*rise+3])sphere(d=thinwall,center=true,$fn=16);
        rotate([0,0,(i-1)*angle])translate([radius+width,0,(i-1)*rise+3])sphere(d=thinwall,center=true,$fn=16);
        }
    }
    for (i=[0:steps]){//vert handrail supports
        rotate([0,0,i*angle])translate([radius+width,0,i*rise+1.5])cylinder(d=thinwall,h=3,center=true,$fn=16);
        }
    
    The code above produces this model:
    Stairs.jpg
     
    Last edited: Jul 24, 2018
  2. southernnscale
    southernnscale Well-Known Member
    Cool! uploaded program. and used the above information and it's right there in front of me! Must be great to be able to figure out these things with out even drawing it! took me less then a min to do this!
    Capture.PNG
     
    Last edited: Jul 24, 2018
  3. southernnscale
    southernnscale Well-Known Member
    This one I did with 3D max took me about 3mins. 20ft x 20ft
    tank.jpg
     
  4. Ngineer
    Ngineer Well-Known Member
    I tried to draw this in Autocad and it took me a long time, I'll try this. Thanks Stony!
     
  5. MrNibbles
    MrNibbles Well-Known Member
    Tinkercad recently added a scripting capability. It might be worth a try.