| 
     
      
      
      From: Chris W. <cw...@ua...> - 2003-08-20 18:05:01
       
   | 
Hello,
My name is Chris Want, and I do visualization support at
the University of Alberta -- and in particular I run the
university's 3D printer.
I'm not a pymol user per se, but I have had a
client who really liked the 'surface' visualization
from pymol and wanted to print some molecules off
on the 3D printer. Unfortunately, pymol lacks an
export export option for the 'STL' format, so
I crafted together a little hack that quietly dumps
out an STL file when a surface is created, which I
hope may be of use to other users (or perhaps somebody
who finds it useful, and who also has an
understanding of the pymol user interface
code, can create a button for it).
Here it is (sorry it's not in a proper 'diff'
format -- I'm not using cvs code):
File layer2/RepSurface.c, 2 modifications:
1) Add this function:
void DumpStlAscii(char *filename, RepSurface *I) {
   FILE *fpSTL;
   float *x, *y, *z;
   int a;
   fpSTL = fopen(filename, "wb");
   fprintf(fpSTL, "pymol molecule\n" );
   for (a=0; a < I->NT; ++a) {
     x = I->V + 3*((I->T)[3*a]);
     y = I->V + 3*((I->T)[3*a+1]);
     z = I->V + 3*((I->T)[3*a+2]);
     /* We'll let whatever app opens this file
      * deal with the face normals.
      */
     fprintf(fpSTL,
             "  facet normal 0.0 0.0 0.0\n"
             "    outer loop\n"
             "      vertex %g %g %g\n"
             "      vertex %g %g %g\n"
             "      vertex %g %g %g\n"
             "    endloop\n"
             "  endfacet\n",
             x[0],x[1],x[2],
             y[0],y[1],y[2],
             z[0],z[1],z[2]);
   }
   fprintf(fpSTL, "endsolid\n" );
   fclose(fpSTL);
}
2) In the function RepSurfaceNew(),
locate these lines:
       PRINTFB(FB_RepSurface,FB_Details)
         " RepSurface: %i triangles.\n",I->NT
         ENDFB;
Add the following function call immediately
after the above lines:
       DumpStlAscii("/tmp/pymol.stl", I);
Now, when the 'surface' is calculated, it's geometry
is dumped to the file /tmp/pymol.stl.
I Hope this is useful to somebody!
Regards,
Chris
P.S. I wish this mailing list had archives ...
-- 
Chris Want
Research Computing Support
Computing & Network Services
University of Alberta
Tel: 1-780-492-9418
 | 
| 
     
      
      
      From: Warren L. D. <wa...@de...> - 2003-08-22 05:05:42
       
   | 
Thanks for your code! > P.S. I wish this mailing list had archives ... But it does! http://sourceforge.net/mailarchive/forum.php?forum_id=60 You can search by keyword. Look for the text box upper-left. Cheers, Warren  | 
| 
     
      
      
      From: Chris W. <cw...@ua...> - 2003-08-20 22:48:03
       
   | 
Hi Darren, Rob, >>P.S. I wish this mailing list had archives ... > > > But it does! > > http://sourceforge.net/mailarchive/forum.php?forum_id=60 > > You can search by keyword. Look for the text box upper-left. Thanks for pointing this out! I could have sworn the thing said 'No archive available' yesterday -- might have been an effect of the Sobig e-mail worm, maybe. Cheers, Chris -- Chris Want Research Computing Support Computing & Network Services University of Alberta Tel: 1-780-492-9418  | 
| 
     
      
      
      From: D. J. A. <de...@ia...> - 2003-08-28 18:40:47
       
   | 
On Wed, Aug 20, 2003 at 11:54:26AM -0600, Chris Want wrote: > > I'm not a pymol user per se, but I have had a > client who really liked the 'surface' visualization > from pymol and wanted to print some molecules off > on the 3D printer. Unfortunately, pymol lacks an > export export option for the 'STL' format, so > I crafted together a little hack that quietly dumps > out an STL file when a surface is created, which I > hope may be of use to other users (or perhaps somebody > who finds it useful, and who also has an > understanding of the pymol user interface > code, can create a button for it). Thanks for the code! I find the prospect of using this pretty exciting, and hope Warren can incorporate the function and (a) way(s) to call it into the distributed code. I hope to steal some time to try to try this out here, and to try to convince the folks who run the 3D printers on campus to let us print some things. For future reference, with what version of PyMOL, running in which environment, have U Alberta used this code? It looks pretty straightforward, but you never know. Also, if you or your client would like to comment at all about the size of PyMOL files that have been printed (both in terms of output object dimensions as well as numbers-of-atoms or molecular weight), I'd be very interested in reading about it. (From reading the general description of your facility I can translate, for instance, size into print times, but whatever PyMOL-specific details you want to provide would be great.) Best Regards, --Joe -- D. Joe Anderson, Asst. Sci. 2252 Molecular Biology Bldg. BBMB Research Computing Support www.bb.iastate.edu/computing bbs...@ia...  | 
| 
     
      
      
      From: Chris W. <cw...@ua...> - 2003-08-29 18:06:22
       
   | 
Hi Joe, > Thanks for the code! I find the prospect of using this pretty exciting, and > hope Warren can incorporate the function and (a) way(s) to call it into the > distributed code. > > I hope to steal some time to try to try this out here, and to try to > convince the folks who run the 3D printers on campus to let us print some > things. > > For future reference, with what version of PyMOL, running in which > environment, have U Alberta used this code? It looks pretty > straightforward, but you never know. I was running 0.90 compiled from a source tarball, running under Debian Linux. > Also, if you or your client would like to comment at all about the size of > PyMOL files that have been printed (both in terms of output object > dimensions as well as numbers-of-atoms or molecular weight), I'd be very > interested in reading about it. The molecules were 2 serotonin receptors and 12 serotonin molecules. Dr. Warren Gallin, the researcher that commisioned the print job, has sent you some files and some more detailed info about the science involved. The actual sizes of the printed serotonin receptors were about 5" x 5" x 4" and the serotonin molecules were about 1" x 1" x 1/4". A screenshot of one of the serotonin receptors in pymol is here: http://bebop.cns.ualberta.ca/~cwant/wgallin-pymol.jpg A picture of the printer output of the receptor with an orientation roughly matching the screenshot, and a few serotonin molecules, is here: http://bebop.cns.ualberta.ca/~cwant/wgallin-3d-printed.jpg (I hope this is the right molecule ... the 2 receptor molecules were visually quite similar.) The 8.5" x 11" paper underneath the molecule should give a decent indication of the size of the output. > (From reading the general description of your facility I can translate, for > instance, size into print times, but whatever PyMOL-specific details you > want to provide would be great.) The size in the stl file doesn't matter -- the 3D printing software allows scaling to any size desired that will fit within the machine's build volume. The only thing to note here is that we had to scale all of the molecules by the same factor for the output to be meaningful. Regards, Chris -- Chris Want Research Computing Support Computing & Network Services University of Alberta Tel: 1-780-492-9418  |