Show HN: LuaCAD – Parametric CAD Scripted in Lua

(luacad.ad-si.com)

91 points | by adius 16 hours ago

8 comments

  • psd1 20 minutes ago
    A scripting engine is a great feature in cad, you should be proud of your achievement. The reason I'm not personally interested is that i used lisp in AutoCAD in the 00s. What i like most about lua is that it's not php. It's a sane choice, but insipid.

    https://www.cadtutor.net/tutorials/autolisp/quick-start.php

  • fhn 13 hours ago
    Does this have a web-based playground? I find https://www.pythonscad.org/playground/ to be nice to try out the project.
    • adius 13 hours ago
      Agreed! I’m already working on it, but it’s not quite ready yet. ETA is 1-2 weeks.
  • tolugenius 15 hours ago
    Really interesting! I actually use freecad so I'm use to that layer of the process but I'll check this out. Also good to see the work being done in modeling software these days
  • manny_rat 15 hours ago
    Love it! OpenSCAD has very painful syntax. Is it possible to easily do bevels/chamfers or does it have the same limitations as OpenSCAD there?
    • adius 14 hours ago
      Thanks! It natively supports all BOSL2 functions which include a chamfer argument (https://github.com/revarbat/BOSL/wiki#common-arguments). So that makes it quite straightforward to add chamfers to everything!
      • kragen 13 hours ago
        Can you fillet unions? Like, if I union a cube with a smaller cube sticking out of its side, can I make a fillet so that the edge where the two cubes' faces intersect doesn't become a stress concentration point for cracks to start at? This is OpenSCAD's primary weakness from my point of view.
      • addaon 14 hours ago
        Which is what separates us from the animals.
      • adastra22 12 hours ago
        Quite easy to add chamfers to everything in the CAD file. But your manufacturing guy is going to strangle you...
        • gunalx 8 hours ago
          So ill strangle myself while the 3d printer goes back and forth.
  • WillAdams 15 hours ago
    Is it able to access the file system and write/read files?

    I've been doing that via PythonSCAD for my current project https://github.com/WillAdams/gcodepreview and it might be interesting to do a re-write in another language.

    • adius 15 hours ago
      Yes, it executes in a full fledged Lua environment. So you can do all the things you expect do be able to do with Lua!

      I’d pick Lua over Python any day, but maybe that’s just me. ;-)

      • WillAdams 13 hours ago
        I've had good success w/ using Lua in LuaLaTeX, so hopefully a good fit for me to exercise my programming chops. I think it will be interesting to maintain two parallel versions for comparison/contrast. Thanks!
  • lkjdsklf 6 hours ago
    The change history on this repository is fascinating
  • adastra22 12 hours ago
    Isn't OpenSCAD's limited (non-Turing complete) language a feature?
    • adius 12 hours ago
      I'm pretty sure it's Turing complete by now. If it was conceptualized as a limited language and only became a full fledged programming language over time, it would certainly explain all its weird warts. (Here is some more details: https://github.com/ad-si/LuaCAD#why-lua) I guess 3D modeling is just too complex for a simple, but limited DSL.

      Lua is easier to use, faster, and more feature-rich. It's one of those rare occasions when a new solution is actually better in every single way.

      • adastra22 12 hours ago
        In the pedantic sense, yes. You can use recursive functions with tail-call optimization, or list comprehensions to emulate a universal Turing machine.

        But my point is that OpenSCAD's expression purity and one-way compilation model are purposefully limited, and not historical accident: models are a deterministic function of their parameters, subtrees can be cached and reused during preview without invalidation logic, designs diff and merge as text, etc.

        Sometimes making things "more programmable" is an anti-feature.

        • cjbgkagh 6 hours ago
          AFAIK OpenSCAD does not do any meaningful optimizations that are enabled by having a limited DSL, despite that normally being a good reason to do a DSL. And ironically you often have use a general purpose language (python and C++) to do custom optimizations not possible in the DSL.
  • kiops 6 hours ago
    [flagged]