Export Blender scenes to Asymptote source code
Closed, ArchivedPublic

Description

Project: Blender Extensions
Tracker: Py Scripts Upload
Category: Import Export
Python: 2.5
Script name: Asymptote Export
Wiki page: ?
Dependencies: math, os
Author(s): Scott Pakin
Status: Closed

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.

Details

Type
Patch

Uploading Asymptote Export version 1.1, a bug-fix release:

* Modified the mesh-outputting code to sort the faces (roughly) from farther to nearer because 2-D Asymptote output is drawn in program order without hidden-line removal.

* Corrected the way lights are handled. I had previously thought that Asymptote specifies a light as a position with no direction. However, I now believe that Asymptote specifies a light as a direction with no position. (I haven't yet found any documentation that states this explicitly, however.)

closing, we review only scripts for 2.5

Note that even after closing it, this tracker page will still be available, so no worries :)

By the way, if you want to, you could port it to 2.5 :)

mindrones closed this task as Archived.Dec 24 2010, 1:19 AM

Hi!
I'm using Blender v2.69.

I installed this script like you said and even active it by running the script directly from the "script" folder but nothing append so i wonder if this script is to old or if I did something wrong..

@derpman (jurta):

I'm using Blender v2.69.

I installed this script like you said and even active it by running the script directly from the "script" folder but nothing append so i wonder if this script is to old or if I did something wrong..

The former; the script is too old. I haven't yet had time to port it from the Blender 2.4 API to the Blender 2.6 API, which, alas, is completely different. Sorry about that.

Thanks for your interest,
— Scott