CAD.py

Eric Carlson ecarlson at eng.ua.edu
Mon Nov 3 09:29:45 EST 2008


Hello,

I have pondered this notion of a 3d sketcher a bit myself. Before I go 
on, here is a quote from writer Neil Gaiman, author of some very good books:

"Every Published writer has had it - the people who come up to you and 
tell you that they've Got An Idea. And boy, is it a Doozy. It's such a 
Doozy that they want to Cut You In On It. The proposal is always the 
same - they'll tell you the idea (the hard bit), you write it down and 
turn it into a novel (the easy bit), the two of you split the money 
fifty-fifty"

In this spirit, let me offer the following observations/suggestions:


Mayavi, the open source data visualization system from enthought.com, 
does a very nice job of high-level wrapping of The Visualization 
Toolkit. VTK has both high-level wrappings of OpenGL for display, as 
well as many modules to import/export various 3D file formats, merging 
or clipping 3D objects, constructive solid geometry, etc. All of the 
lower-level VTK routines can be accessed through the traited VTK wrapper 
(TVTK) from enthought. Once you have a Mayavi scene, it is a simple 
matter to add anything to it, or to modify any of the objects in the scene.

Although Mayavi has evolved to be reasonably backend independent, the 
current version interacts most easily with the wxpython GUI toolkit. 
Given that they work well together, I would say that a combination of 
wxpython, Mayavi, and enthought Traits (recent stable versions and 
Python 2.5) could lead to a very interesting 3d sketching application.

If you install the wxpython demos and samples (an absolute necessity if 
you program with wxpython), you can dig through the installation 
directory and find a "samples" subdirectory, and in there you can find 
another folder called "pySketch." This app is a nice 2D sketching 
program with everything I really need for simple 2D sketches, except 
rotating objects (and I had to hack it to get a button to save an image 
and copy to clipboard) - it could probably also use buttons for various 
common drawing objects. If nothing else, this example might give an idea 
of a possible layout, and source for how to set it up.

For the 3d sketching, you would have to have some buttons for object 
creation (various polyhedra, sphere, ellipse, arbitrary explicit 
function, implicit function, constructive solid geometry surface, maybe 
a library of predefined widgets), extruding, surfaces of rotations, 
button or menu for importing/exporting an object, some buttons for 
clipping and merging objects (additive and subtractive merges), some 
buttons for object transformations (scaling, rotations, precise 
placement in a scene, parametric stretching, twisting/turning, mirroring 
objects), button for duplications, and buttons for setting object 
materials/colors/properties.

There are many examples of embedding a mayavi scene in other 
applications given in the examples directory at the mayavi/tvtk 
developer repository.

Also, I have come to appreciate very much the wxpython AUI managed 
frame, which lets you move panels, toolbars, whatever, to pretty much 
any location within your frame. This means that anyone using your 
application can customize their layout with trivial effort.

I doubt that I can get around to any of this until late next year, but I 
would be happy to assist if you want to take a shot at it...

Cheers,
Eric Carlson




More information about the Python-list mailing list