First try.
tidied up for general use.
updated scad stuff.