Python OpenSCAD Script

For my Numerical Methods Q4 project, I made a code that made a code that makes an object. In better terms, I created a code in Python which made a code in OpenSCAD which made an object for me to 3D print. I started making a code to make simple blocks and then added a sin function to make it wavy. I experimented a lot with the sin, cos, and tan functions to make the end object look different. For my specific project I made an object using a sin function.

import math
for i in range (50):
    h=9*math.sin(0.5*i)+10
    b=i*10
    print("translate([%d,0,0])"%(b))
    print("cube([10,10,%d]);"%(h))

Leave a Reply