Python 3D CAD -- need collaborators, or just brave souls :)

Mike C. Fletcher mcfletch at vrplumber.com
Tue Feb 10 13:07:50 EST 2009


rantingrick wrote:
...
> It has long been my dream to create an open source 3D CAD program and
> i am starting to crawl my way into the first steps. I now believe i am
> ready to start this endeavor and i am currently looking for fellow
> Python programmers (no matter what skill level) to get started
> brainstorming this design.
>   
I'm certainly willing to help with brainstorming...
> Of course Python will limit the speed here, but at this point i want
> to get a template up and running. Speed does not matter at this point,
> and optimizations can come along later as i am sure a few complete re-
> writes are inevitable :)
>   
Simple CAD systems without shading/texturing shouldn't have any real 
performance issues under Python.  We had 3D CAD back in 1993 sufficient 
to build reasonably complex environments when I was in architecture.  
Python's only about 10x slower than C, and if you dump large C-level 
arrays into the graphics card your performance can be quite reasonable.  
If you have a visit @ every face/line for every refresh you'll spend all 
your time in the scenegraph traversal.
> There will need to be mouse picking as i see this application as a
> very interactive environment. Of course in the beginning all
> interaction will most likely be in a command line type manner until
> the functionality can be worked out.
>   
Mouse picking is pretty easy, you can either use simple ray-intersection 
on your bounding-box hierarchy (easiest/fastest for CAD-type structures) 
or render-pass based stuff (if you have lots of organic shapes that will 
show through each other a lot and you want to be able to click on the 
thing "peeking through" behind another thing.  Both are very well 
documented and easy/fast to implement if/when your scenegraph is 
tracking bounding volumes.
> There will need to be a hierarchy of instancing and grouping within
> the model to facilitate easy transformation of entities within the
> model.
>   
Transform and Group nodes are definitely a good idea, as are "USE" nodes.
> I am not too worried about any sort of texturing at this point. I want
> to squeeze as much speed as possible and prettiness will come in due
> course. I also have no plans for layering, or multiple scenes at this
> time. Simple functionality is the end game here.
>   
Fair enough.
> #-- Entities --#
>  face
>  line-segment
>   
That's pretty low-level.  You may want to work with "meshes" or the 
like, so that you select the mesh, then modify the faces/vertices/edges 
(a-la 3DSMax/Maya), particularly where you want faces to share 
coordinates.  Just a thought.
> #-- Hierarchy --#
>  Entity (one face, or line-segment)
>   
Again, seems like you'd want something a little less soup-of-lines-ish, 
but then that's a 3D Modeler bias, rather than a CAD bias (where often 
it really is just a soup of lines).
>  Group (contained of multiple entities that can be translated,
> rotated, scaled as one)
>   
Transform node.
>  Instance (component definition)
>   
Node with DEF + USE's node instance.  Or, if you mean a reusable, 
parameterized node, a PROTO definition and PROTO-using nodes.
> #-- Tools --#
>  line
>  rect
>  circle
>  arc
>   
You'll want mechanisms to define the current coordinate system as well 
(think AutoCAD "UCS") so that you can precisely align the work you are 
doing without needing to calculate cos/sin/tan for everything.  That is, 
your rotation/translation/scale should allow you to draw *within* the 
resulting Transform.  You'll likely also want to be able to translate 
objects to/from Transform spaces (i.e. reparent without moving).

Also (from my many-year-old recollection of doing CAD in architecture):

    * tan (when you want to draw lines tangential to a circle/arc and
      then trim)
    * chamfer/fillet (easy to code and pretty darn useful for a lot of
      detail drawings)
    * copy
    * align
    * delete/erase
    * hide/show hidden edges
    * mirror/mirror3d (used it all the time)
    * text (pretty important for CAD work)
    * snap control (critically important IMO)
    * polyline/polygon (or tools to combine lines/arcs into polygons and
      close the result for e.g. extrusion)
    * splines/nurbs or other high-order surfaces (eventually)
    * boolean operators (eventually, use a library for this unless you
      really want to learn, and even then, do it yourself and then use a
      library)

>  select
>   
Critical to get that right to make it usable.
>  rotation
>  translation
>  scale
>   
I'd suggest a Maya-like control for this as far as the GUI goes, put 
snaps on it, but make a single widget that lets you 
rotate/translate/scale.  You'll also want such things as 
scale-this-line-to-be-this-size rescales (scale, pick two points, pick 
two other points, scale is the relative length of the two points)...
>  extrusion along path
>   
Available in GLE extensions (nodes available too).  Also want "revolve" 
(extrude around a path, which may be a point).  Depending on your model, 
you may want to allow for converting extrusions to faces in order to 
allow tweaking the resulting extrusion.  You'll want/need a UI to "open" 
the extrusion and change the backbone and sweep shapes.
>  measurement
>   
measurement == dimensioning (dim*)?  Or just on-screen measurement 
(dist).  Both are useful.
> So there it is. Any takers? :)
>   
I can't even begin to commit any real time to another project (I barely 
have time to work on the ones I already have), but if you need feedback, 
feel free to email me.  Most of the graphics stuff sounds like stuff you 
could build on top of OpenGLContext or COIN or any of the generic 
scenegraph libraries.  They aren't really CAD-focused, but they've 
already got the ability to draw the things you're wanting to work on, 
and have the Transforms and similar support to make the coding a 
reasonable task.  However, they're closer to a Maya/3DSMax model than 
AutoCAD, so maybe you'll decide you want to go your own way.

You may want to check out PythonCAD as well, which IIRC does 2D-only CAD.

Anyway, hope this was some help.  Good luck,
Mike

-- 
________________________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://www.vrplumber.com
  http://blog.vrplumber.com




More information about the Python-list mailing list