I have been thinking for a long time to get hands on with OpenSCAD. It is a programmers Solid 3D CAD modeller. Part of my python readings, I was looking for different fields or area of interest where python can be used and went through something called SolidPython. It is a python frontend for solid modelling that compiles to OpenSCAD. Cool I quickly installed both the packages.
sudo apt-get install openscad sudo pip install solidpython
I played around an example code and got a cube working. The code is here I will explain how I created the model
end of the blog
#! /usr/bin/env python # -*- coding: UTF-8 -*- from __future__ import division import os, sys, re from solid import * from solid.utils import * from solid import screw_thread def assembly(): c = cube(10) return c if __name__ == '__main__': out_dir = sys.argv if len(sys.argv) &gt; 1 else os.curdir file_out = os.path.join( out_dir, 'cube.scad') a = assembly() print(%(__file__)s: SCAD file written to: \n%(file_out)s %vars()) scad_render_to_file( a, file_out, include_orig_code=True)
I will explain how I created the cube model as shown above.
Save the python code and execute it as follows
$ python cube.py cube.py: SCAD file written to: ./cube.scad
This will generate cube.scad file.
Now run the OpenSCAD and open the cube.scad and type ‘F5’ or in the menu Design->Compile.
You will get this output.