Pages

Monday, March 28, 2011

Extending OpenSCAD


I spent the weekend hacking on openSCAD, and I thought people might be interested in the results. The most visible one is syntax highlighting, but I've also done a few language extensions:
  • Dot/Cross Product (* and %)
  • length function for lengths of vectors and strings
  • accessing characters in a string via []
I've got a more detailed post on my blog (including some future ideas) or you can just grab the code from github. Note that my work is not yet merged into mainstream openSCAD.

2 comments:

  1. Thank you! I was dying without syntax highlighting!

    ReplyDelete
  2. Cool! My wishlist :-) ... :

    1. Measurement ticks on the axes that look like rulers that one can
    turn off and on.

    2. Can you easily ray-trace into the image? If you can, then it's
    pretty easy to implement a whole load of measurement tools...

    About 20 years ago my old colleague Andy Wallace did this with a CSG
    modeller. You ray-trace from the pixel where the mouse is to find the
    surface that gets hit - that is the point in 3D that the user has
    indicated. Then you can:

    Report the 3D coordinates of the hit point.

    Ray-trace through the solid at right angles to the hit surface to the
    exit and report the thickness of what's pointed at. This gives web
    thickness and cylinder diameter and so on.

    Ray trace outwards at right angles to the hit surface and report
    what's hit that way. This gives the slot width and the diameter of
    cylindrical holes.

    Point at two surfaces and report the distance between the two points
    indicated and 1) if they are parallel, the perpendicular distance
    between them, and 2) if they are at an angle, the angle between them.

    And so on. Just one function (ray trace and measure distance along
    the ray) allows an incredibly rich and useful set of functions to be
    built easily.

    ReplyDelete