Project: Blender Extensions
Tracker: Py Scripts Upload
Category: Import Export
Script name: Asymptote Export
Wiki page: ?
Dependencies: math, os
Author(s): Scott Pakin
The Asymptote Export script exports the current Blender scene as Asymptote code. According to the Asymptote Web page [http://asymptote.sourceforge.net/], "Asymptote is a powerful descriptive vector graphics language that provides a natural coordinate-based framework for technical drawing." Two features of Asymptote make it an exciting export target for Blender. First, it (normally) renders a scene as a vector graphic, not a bitmap, so the output doesn't lose quality when scaled. Second, Asymptote can output 3D graphics in PRC format [http://en.wikipedia.org/wiki/PRC_(file_format)]. PRC images, like U3D images [http://en.wikipedia.org/wiki/U3D], can be embedded in a PDF file and presented as interactive 3D models when viewed with Adobe Acrobat and Adobe Reader or as ordinary, noninteractive graphics when viewed with any other PDF reader. In fact, the LaTeX typesetting system [http://www.latex-project.org/] can include PRC models in a document almost as easily as it can any other graphics format. Hence, Asymptote Export supports a workflow in which a 3D model produced with Blender can be incorporated into a document alongside text, hypertext, graphics, and other media -- all using exclusively open-source tools.
Asymptote Export processes the world, the current camera, all lamps, and all Blender objects that can be converted automatically to meshes. It honors material colors, vertex colors, and the set of visible layers. It outputs commented Asymptote code in which each block of code is associated with the Blender object that it represents. Unconvertible Blender objects are also listed in a comment for reference.
To install Asymptote Export, simply copy the asymptote_export.py script to your Blender scripts directory. ("Blender 3D: Noob to Pro" says where this is for various operating systems [http://tinyurl.com/2cpa52u].) The next time you start Blender you should have an "Asymptote (.asy)..." menu item under File->Export. Asymptote Export has no options; after drawing your scene, simply go to "File->Export->Asymptote (.asy)..." and enter the name of a .asy file to create. Run Asymptote as normal on the result. For example, running "asy -f pdf -k myfile.asy" will produce a PDF file (-f pdf) with your 3D model embedded within it while keeping (-k) the various intermediate files. The most useful intermediate file is the one with the .prc extension; this is the 3D model proper.
When viewed in Acrobat, the generated model will rotate around the camera's clipping endpoint. If this is set too far from the objects in your image, the objects will quickly rotate off the screen. To set the endpoint properly, select the camera icon (RMB), choose Editing (F9), shift-LMB on "Clipping Start/End: End", and enter a number. I find it also helps to select "Show: Limits" to tell Blender to draw the camera's extent as a line protruding from the camera icon.
Asymptote Export has been tested under Debian GNU/Linux 5.0 ("Lenny") using Blender 2.46, Python 2.5.2, Asymptote 2.04, and Adobe Reader 9.3.3. Asymptote's 3D support seems to be undergoing frequent interface changes so the .asy files produced by Asymptote Export may need to be edited manually to work with older versions of Asymptote.