Converting crystal structures to printable files

Discussion in 'My Work In Progress' started by chemdr99, Apr 12, 2012.

  1. chemdr99
    chemdr99 New Member
    I work with crystals at my job (think diamonds, rubies, etc. but nothing so expensive) and I use a software known as Diamond crystal structure visualization which generates 3D renderings of the atomic arrangements of the atoms in crystal structures. It has all of the xyz coordinate data to produce 3D design files that would be printable, but it isn't formatted to save in any file type that is recognizable by typical design software (SketchUp, MeshLab, netfabb, etc.) If anyone has any ideas about how to go about importing this data, I would greatly appreciate it. I know I could just sit down and put in each atom by hand as spheres and connect them all with tapers, but the scale I want to use would take forever and if I already have the xyz data, I would rather just use that. The Diamond software is available as a demo download on their website, so if someone has the time (and inclination to help), you can download it and see for yourself.
    Thanks in advance.

  2. stonysmith
    stonysmith Well-Known Member Moderator
    Can you share a copy of such a file? Either publicly or thru PM would be fine.
  3. stop4stuff
    stop4stuff Well-Known Member
    Try export

    VRML2.0(97) a .wrl file is one of the filetypes Shapeways accepts. If Diamond outputs the VRML1.0 filetype, use Meshlab or NetFabb Basic to convert to whichever filetype you want to upload.

    From Shapeways FAQ;
    "You can upload STL, VRML2/97 (.wrl), COLLADA (.dae), X3D and OBJ files to Shapeways. Many modeling applications support these file formats. If you need to convert to them we recommend Accutrans or Meshlab."

    If you don't need colour in the print, I recommend using NetFabb both for conversion (to stl) and error checking.

  4. stonysmith
    stonysmith Well-Known Member Moderator
    chemdr99 and I are exchanging PM's about this... it seems the WRL witten out by "Diamond" is not directly compatible with Meshlab. I was able to get it to load into Truespace, and flip it to VRML2.0, but that's a kludgy way of dealing with it.

    I'll post more as we figure out something.
  5. henryseg
    henryseg Well-Known Member
    If you have the coordinates of each atom, and a list of the edges to be drawn between atoms, then in principle it shouldn't be too hard to write a script to build the geometry from that data. I would use Rhino and the Python scripting interface.

    You might find that the meshes used to visualise the geometry aren't watertight, or aren't very high resolution (e.g. tubes have only a small number of sides, when you'd prefer them to be rounder). Both of these issues aren't a problem for just drawing things on screen, the latter particularly when they lack of roundness can be hidden using shading.

    So it might be better to rebuild from scratch, which also lets you play with the relative thickness of lines and size of balls around the atoms etc.
  6. damocles
    damocles New Member
    Do that, find surface atoms, assume atoms are mesh vertices, iteratively split any nontriangular surface facets, then write to ASCII STL. Should work, plus or minus some debugging. From there, go back and fiddle with vertex choice and initial facet choice to tweak the results if needed.

    Alternately, output atoms as point clouds and try to fit a mesh in MeshLab (etc.). Less work, but probably less ideal results.
  7. stonysmith
    stonysmith Well-Known Member Moderator
    I figured out a workflow to convert the Diamond software's output to STL format using a bit of manual editing and then using AccuTrans to do the actual conversion. I sent it to chemdr99 and he can share if he wants to.

    I have been casually researching how to build models such as this. I've got a snippet of OpenSCAD code that will place the connecting cylinders between the sphere centers. The advantage would be tht with OpenSCAD, you could easily pick your number of facets and make the model very smooth. The trouble is positioning the spheres (atoms), and the Diamond software is doing a good job of that. Perhaps someone can work out the other info needed for calculating the relationship of the atoms in OpenSCAD.

    Now if we could just print individual atoms for real :D .. anybody up for a molecular printer? Talk about THIN walls :D
  8. chemdr99
    chemdr99 New Member
    Thanks to Stony, I have a sufficiently efficient workflow from crystal data (.cif) to printable .stl file. Probably due to the use of all-free programs, I have to go through a few programs, but it is well worth the few extra mouse clicks.

    I start with the .cif crystal data file I open with Diamond (manipulation of the data in Diamond is a whole other message and something you can probably follow better from a tutorial website) and export as .wrl.
    In Notepad, I manually increase the radii of the cylinders (atomic bonds) and spheres (atoms) to a more manageable size (right now using 0.15 as cylinder size and 0.5 as atom size - this could also probably be done in Diamond).
    Then, open the edited .wrl file in AccuTrans 3D and export as an .x3d file.
    This file is opened in Meshlab and resaved as .stl,
    Finally, this .stl file is opened in netfabb where all scaling and error correction are performed and the final file is exported as an .stl file.

    And there you have it. I find it efficient enough to get the desired results and you can see the fruits of much labor in my store.

    Thanks again to all for your help and suggestions and especially to Stony for the workflow and AccuTrans3D suggestion. God has really shown Himself in my once-reserved world of chemistry through these crystal structures and I am glad to finally be able to share them with everyone else. He shows up in the large places as well as the very tiny (nano-scale even) and even in a community of strangers connected by a common bond of creativity.

  9. chemdr99
    chemdr99 New Member
    Stony - speaking of printing atoms, you would be surprised what kind of research goes on in academia. I know of a group that is building organs one cell at a time :eek: . Not quite atomic, but getting there