OpenSCAD project: Files to Physicals

Files to Physicals 1

Make 3D models from any file on your computer!

Files to Physicals 1

I’ve recently been fascinated with the idea of representing the things on our computers (music, photos, programs) as physical objects. After learning OpenSCAD for last week’s analog stick project, I tried my hand at a script for taking any file and turning it into a unique 3D model.

A file can be any size, so to have the right amount of input for the script to interpret, it’s necessary to first reduce it to an MD5 hash. The model consists of four “stalks” on a base, so the hash is split into four segments that then represent four hexadecimal values affecting the composition of each stalk.

The parameters for each stalk affect height, radius, twist value, and the radius of a circle fed into OpenSCAD’s linear_extrude() function:

module Stalk(stalk_height, stalk_twist, stalk_extrudetrans, stalk_radius) {

linear_extrude(height = (STALK_HEIGHT_MAX – STALK_HEIGHT_MIN) / 256 * stalk_height + STALK_HEIGHT_MIN, convexity = 100, twist = (STALK_TWIST_MAX – STALK_TWIST_MIN) / 256 * stalk_twist + STALK_TWIST_MIN)

translate([(STALK_EXTRUDETRANS_MAX – STALK_EXTRUDETRANS_MIN) / 256 * stalk_extrudetrans + STALK_EXTRUDETRANS_MIN, 0, 0])

circle(r = (STALK_RADIUS_MAX – STALK_RADIUS_MIN) / 256 * stalk_radius + STALK_RADIUS_MIN);

Each parameter has a minimum and maximum value so that the model is (hopefully!) printable and none of the stalks have a height of zero.

Due to the limited number of string functions available in OpenSCAD, I had to create a web form that takes an MD5 hash and outputs a special include file containing all of the necessary variables for the main script. Basically it just splits up the hash and converts the hex values to decimal.

My own first model (made from a song called Sea Within a Sea by The Horrors) is still printing, but if you’re feeling adventurous here’s how to get started:

  1. Download the script
  2. Calculate an MD5 hash
    • – Mac and Linux users have the command-line tool ‘md5’ built-in
    • – Windows users can download a third-party tool such as FSUM.
  3. Get a data file
    • – Paste the MD5 has into this form:
    • – You’ll be prompted to download an fp_data.scad file
    • – Place that file in the same folder as the Files to Physicals.scad script
  4. Create the 3D model
    • – Open the main script in OpenSCAD
    • – Press F6 to compile and render the model (this wil take a few minutes)
    • – Use the command Design – Export to STL… to export a file suitable for the Personal Factory or for your hobbyist 3D printer

Let me know if you give it a shot!

Derek Quenneville is a 3D printing evangelist who posts weekly on the Ponoko blog. Follow him on Twitter @techknight.