Buckyballs - Molecular Models

by pmoews, published

Buckyballs - Molecular Models by pmoews Oct 19, 2011

Featured Thing!

12 Share
Download All Files

Thing Apps Enabled

Order This Printed View All Apps



Liked By

View All

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag.

Print Thing Tag

Thing Statistics

39109Views 7667Downloads


Here's a simple molecular modeling program written in OPENscad. It's a derivative of the OPENscad program in "Protein Models". It contains two modules, "atom" and "bond". A call to atom makes a sphere and a call to bond makes a cylinder. Atom requires a radius and a set of atomic coordinates; bond requires two sets of atomic coordinates. For example to make a water molecule we could write:

atom (.3, 0, 0, 0); // an Oxygen at the origin, .3 for its radius
atom (.25, -.96, 0, 0); // for the first H atom, .25 for its radius
atom (.25, .24, .93, 0); // for the second H atom
bond (0,0,0,-.96,0,0); // for the first O-H bond
bond (0,0,0,.24,.93.0); // for the second o-H bond

To render it all together the above commands are included within a union statement. More details in makewater.scad.

Once I had this program I began looking for coordinates of interesting molecules to print. I found a collection of fullerenes at http://www.ccl.net/cca/data/fullerenes/index.shtml Better known as "Buckyballs" you can read about the fullerenes on Wikipedia. The buckyball most discussed contains 60 carbon atoms but the coordinate collection has a range of sizes, from 20 to 540 atms.


Buckyballs contain too many atoms to type in directly. The fortran program buckyread.f takes one of the files from the fullerene collection and outputs the atom and bond calls for the openSCAD program.

Files at the fullerene repository are in Chem-3D format. I'm not familiar with the details but it seens to be a fixed format, good for fortran. All of the files in the collection start with an integer in the first three columns of the first record. The integer is the number of atoms in the file. Download one of the files and save it as text. The first record should contain the number of atoms to be read but you might have leading records which have to be deleted depending on how you obtained the file. Use the text file as input to the fortran program which outputs atom and bond calls.

I've included two sample programs makebucky60.scad and makebucky180.scad and their outputs, bucky60.stl and bucky180.stl.

I use a raft and external support to print the buckyballs. They are quite sturdy and can usually be wiggled from the support material in one piece. I've printed balls with 20, 30, 60, 180, 240, and 540 atoms. The upper picture shows examples of 20, 60 and 180 atom bucky balls. The lower picture shows a 540 atom buckyball; not so spherical, it looks like an inflated icosahedron.

Beware - buckyballs with more than 100 atoms take a long time to render.

All Apps

Auto-magically prepare your 3D models for 3D printing. A cloud based 3D models Preparing and Healing solution for 3D Printing, MakePrintable provides features for model repairing, wall thickness...

App Info Launch App

Kiri:Moto is an integrated cloud-based slicer and tool-path generator for 3D Printing, CAM / CNC and Laser cutting. *** 3D printing mode provides model slicing and GCode output using built-in...

App Info Launch App
KiriMoto Thing App

With 3D Slash, you can edit 3d models like a stonecutter. A unique interface: as fun as a building game! The perfect tool for non-designers and children to create in 3D.

App Info Launch App

Print through a distributed network of 3D printing enthusiasts from across the US, at a fraction of the cost of the competitors. We want to change the world for the better through technology, an...

App Info Launch App

Quickly Scale, Mirror or Cut your 3D Models

App Info Launch App

Treatstock is an online platform that offers decentralized manufacturing services such as 3D printing and CNC machining for business-to-business and business-to-consumer sales all over the world. W...

App Info Launch App

3D print your favourite design with NinjaPrototype, a professional 3D manufacture with consistent quality and speed.

App Info Launch App
Comments deleted.

I attempted the C60 with a raft and without support. The little raft could not support the last 10%. I am reprinting larger and with support. Any suggestions on a better way? The supports are EVERYWHERE.

This was great! It's easier to find atomic coordinates for chemicals in molfile / sdf format, so I wrote a python script that takes those as input and creates a scad file (copied below). Thanks for the inspiration!

#!/usr/bin/env python

##             mol2scad           ##
## ------------------------------ ##

## Tool for turning molecular coordinates into SCAD files
## Takes molfile / sdf coordinates as input, outputs a scad file for OpenSCAD

## Andrew J. Bonham
## Version 0.1

## Based on on makebucky.scad at http://www.thingiverse.com/thing:12675

## Useful tool:  http://cccbdb.nist.gov/mdlmol1.asp

## ----------------------------- ##

## Import Dependencies

import sys, getopt

## Main Function 

def main(argv):

        opts, args = getopt.getopt(argv,"hi:o:",["ifile=","ofile="])

    except getopt.GetoptError:
        print 'mol2scad.py -i <input molfile> -o <output scadfile>'

    if len(opts) == 0:
        print 'mol2scad.py -i <input molfile> -o <output scadfile>'        

    for opt, arg in opts:
        if opt == '-h':
            print 'mol2scad.py -i <input molfile> -o <output scadfile>'
        elif opt in ("-i", "--ifile"):
            inputfile = arg
        elif opt in ("-o", "--ofile"):
            outputfile = arg

    ## Import file

    linesTabbed = []

    with open(inputfile) as fileObject:
        linesList = fileObject.readlines()
        for line in linesList:
            column = line.split()

    ## Remove unneeded lines
    indexRemovalOne = [i for i,v in enumerate(linesTabbed) if len(v) < 4]

    linesTabbed = [v for i,v in enumerate(linesTabbed) if i not in (

    ## Split off atoms and bonds lines

    atomsList = [v for i,v in enumerate(linesTabbed) if v[3].isalpha() == True]

    bondsList = [v for i,v in enumerate(linesTabbed) if v[0].isdigit() == True 
        and v[1].isdigit() == True and v[2].isdigit() == True and i != 0]

    ##  Atoms output 
    outputAtoms = []

    for i,row in enumerate(atomsList):
        if row[3] == 'H':
            atomsize = '.4'
            atomsize = '.6'

        outputAtoms.append('atom({0}, {1}, {2}, {3}); // {4} \n'.format(

    outputOne = ''.join(outputAtoms)  

    ### Bonds output

    outputBonds = []

    for row in bondsList:
        partOne = atomsList[int(row[0])-1]
        partTwo = atomsList[int(row[1])-1]
            'bond( {0}, {1}, {2}, {3}, {4}, {5}); // {6} - {7} \n'.format(

    outputTwo = ''.join(outputBonds)

    commonStart = '''/*

    Creates a model of a molcule from a set
    of orthogonal coordinates


    module atom(rx,x0,y0,z0)

    /* spheres of radius rx are placed at the atomic
    positions - x0,y0,z0

    module bond(x2,y2,z2,x1,y1,z1)

    tx = (x2 + x1)/2;
    ty = (y2 + y1)/2;
    tz = (z2 + z1)/2;
    ax = x2 - x1 ;
    ay = y2 - y1;
    az = z2 - z1;

    // rotate command by d moews -
    rotate(a = [-acos(az/sqrt(ax*ax+ay*ay+az*az)), 0, -atan2(ax, ay)])


    output = commonStart + outputOne + outputTwo + '''}'''

    ## Write the file

    with open(outputfile,'w') as f:

## Party!

if __name__ == "__main__":

Buckyballs - Molecular Models
by pmoews

Beware - buckyballs with only 60 atoms take a long time to render if you increase the complexity ($fn=20) but they print better when enlarged :)
Very cool!

The picture you have with all of them in one shot looks like an image from an electron microscope. So awesome!

Did I read that right? Fortran? Holy poop.

This is cool in so many ways! 8-)