[HN Gopher] Show HN: DSLCad - a programming language and interpr...
___________________________________________________________________
Show HN: DSLCad - a programming language and interpreter for
building 3D models
Hey HN. Over the last half a year I have been working on a 3D CAD
programming language called DSLCAD. Today I am here to show my
first release! It is heavily inspired by OpenSCAD which got me
hooked on the idea of a CAD programming language and what it can
do. Please let me know what you think. Ill be in the thread to
answer any questions you may have.
Author : dschroer
Score : 135 points
Date : 2023-02-10 14:58 UTC (8 hours ago)
(HTM) web link (github.com)
(TXT) w3m dump (github.com)
| junon wrote:
| Your LICENSE file is misspelled, by the way.
| dschroer wrote:
| Fixed. Thank you :)
| TheDesolate0 wrote:
| [dead]
| mkeeter wrote:
| Can you say a little more about the geometry kernel? Is it NURBS-
| based, triangles, f-reps, etc?
|
| IIRC, OpenSCAD uses CGAL and is all triangles under the hood;
| other tools use OpenCascade for NURBS modeling, or weirder DIY
| kernels.
| TkTech wrote:
| It's using open cascade.
| digdugdirk wrote:
| Very cool! What modeling kernel does it use?
|
| Out of curiosity - are you a mechanical engineer? I'd be curious
| to know what your history is with different CAD programs, and
| what effect that had on the design/use decisions you made with
| DSLCAD.
| dschroer wrote:
| Its using open cascade.
|
| I am not a mechanical engineer. I am a software developer
| however I have worked closely with engineers and have some
| experience with CAD applications.
|
| Really most of my decisions come from working on larger
| projects in OpenSCAD as well as my contributions to the
| OpenSCAD project (WASM port).
| TkTech wrote:
| It's using open cascade.
| zem wrote:
| quick comment - if you have to note in the readme that it's
| pronounced "diesel cad" you should just rename it "dieselcad" and
| be done with that stumbling block.
| h2odragon wrote:
| I think your front page needs a lot more "what it does" and "what
| it doesn't (yet)". above that it needs a "why this is not SCAD."
|
| I suspect most people bouncing off openSCAD are upset by the
| "programming" language, so I hope yours is simpler and has less
| "functional" annoyances.
|
| Having the first part of your landing page explain how your
| project doesn't require forcing one's mind through the eye of
| those needles like SCAD does would be a great step to get people
| interested in trying to do things with it.
| cjbgkagh wrote:
| IIRC I also think the OpenSCAD language has its issues but I
| wouldn't call them "functional" annoyances. The composition in
| OpenSCAD is really weird in a way that I haven't seen in any
| other language. The unnamed arguments you must access by
| position. The inability to create new types and thus the
| limitations of the kind of types you can work with. The
| workarounds to these limitations are much clunkier than having
| such things supported first class.
|
| I guess it's trying to be accessible to non programmers by
| maintaining a 'simple' interface. But as a programmer I find
| the language really lacking. In theory a restricted interface
| could improve performance but there are so many low hanging
| fruits that OpenSCAD doesn't do that it's hard to imagine that
| performance was a priority and the workarounds end up costing
| much more in performance.
| Brian_K_White wrote:
| A functional aspect of openscad is you can never modify a
| variable.
|
| You have to write some pretty obtuse contortions to do some
| pretty common and useful things, just because of that.
| avmich wrote:
| Well, OpenSCAD isn't Turing-complete. What do you mean, you
| have to write? OpenSCAD focuses on scene description... I'm
| not sure what you mean here?
| dTal wrote:
| Be careful when asserting that things are not Turing-
| complete! I'm fairly sure OpenSCAD is indeed Turing-
| complete, if you discount the recursion limit of 1000000
| (it even sports tail call optimization, so I'm not quite
| sure why it even has a recursion limit).
|
| <edit> apparently the recursion limit is a deliberate
| feature to prevent infinite loops, as there is currently
| no way to interrupt such loops.
| dschroer wrote:
| Thanks for the suggestion. Ill see what I can add to make it
| clear.
| mk_stjames wrote:
| If you haven't seen it you may want to check out
| https://github.com/zalo/CascadeStudio
|
| From what I see, it is exposing the OpenCascade base commands
| directly, versus your completely new DSL, but you might be
| interested in a way to implement your DSL on top of such an
| interface such as this which takes out a lot of the extra work of
| having a rendering interface, exports, etc, maybe.
| gfodor wrote:
| If you like the idea of a "markdown for 3D models", you should
| definitely check out Smooth Voxels: https://svox.glitch.me/
|
| I have a fork of it that is faster and also command line tools to
| make working with these kinds of objects UNIXy.
| https://github.com/webspace-sdk/smoothvoxels
| trehans wrote:
| This is great! I've been looking for something like this for a
| while. My only question is: does this do constraint-based
| modeling like other CAD software or do you have to specify
| individual parameter values?
| dschroer wrote:
| Hey. I'm glad that this is what you are looking for. At the
| moment there isn't constraint based modeling. However given
| that you have a programming language at your disposal you can
| model your constraints yourself.
| trehans wrote:
| Thanks for the reply!
|
| Would you accept a PR for first-class support for specifying
| constraints between variables (and object measurements) as
| part of the language or would that be divergent with the
| goals of the language? I find it to be an important part of
| SolidWorks etc. because often times I'm trying to build
| something where I know one of the dimensions is constrained a
| certain way but that's not how I'd parameterize the object.
| And I don't want to be doing math for e.g. calculating the
| diagonal over and over again as part of calculating parameter
| values or modeling constraints, I like that in Solidworks
| that's part of the package. I believe this issue is important
| to other mechanical engineers as well.
|
| However I do want to say, great work, I think a programming
| language is a great step forward for CAD regardless, and this
| project seems to be pretty well done!
| dTal wrote:
| This is great, we need more of this sort of thing. Huge kudos for
| making it and documenting it. I will definitely be taking it for
| a spin.
|
| 1) Do you plan to add 'loft'? Without it, or some other type of
| morphing extrude, one is severely limited in the types of shapes
| it is possible to create.
|
| 2) I hope you don't mind me asking, what is the psychedelic-
| looking image I can see a sliver of in the screenshot? It looks
| like a rocking desktop background.
|
| By the way, if you're not already aware of it, you may also be
| interested in looking at ZenCad for inspiration. It attempts to
| fill a similar niche (OpenSCAD-ish modeling + OpenCascade),
| except it uses Python.
| dschroer wrote:
| Thanks for checking it out. I am glad you like it.
|
| 1. Now that you have asked for it, I certainly plan on adding
| `loft`. Thank you for the suggestion. Looking quickly it looks
| quite reasonable to implement. I would expect to add it in the
| near future.
|
| 2. It is a digital art coloring book image that I filled in and
| used as a background.
| virtualritz wrote:
| Here is another programmable CAD project, Fornjot[1], also in
| Rust. Fornjot, too, is being actively developed.
|
| Unfortunately it uses Rust for model description (compile
| times/learning curve).
|
| That said, one could probably easily put a layer of scipting
| lang in-between. E.g. Rhai[2] or Lua or whatever.
|
| And I guess if their tech is solid enough, someone will do that
| eventually and open a PR or fork the project. They do not use
| an existing geomtry kernel but do everything from scratch which
| makes this a very interesting endeavour.
|
| There also seems to be a goal overlap between Fornjot and
| DieselCAD
|
| [1] https://github.com/hannobraun/Fornjot
|
| [2] https://rhai.rs/
| loa_in_ wrote:
| See also open source Pov-RAY. Not my software. It has full
| featured boolean volumes, and could be called text based Blender.
|
| http://www.povray.org/ https://github.com/cyborg5/pov2mesh
| dTal wrote:
| It couldn't; POV-Ray outputs images, not meshes or CAD models.
| It is purely a graphics tool.
| zellyn wrote:
| It might be nice to be able to install it with homebrew on MacOS.
|
| btw, I know it's not open source, but you might be interested in
| KittyCAD: I believe they're looking for software developers with
| CAD experience. And you could do worse than work with Jessie
| Frazelle!
| dschroer wrote:
| I am not very familiar with the homebrew packaging process. I
| would be happy if someone wants to help set that up.
|
| Ill take a look into KittyCAD. Seems like a cool idea and is
| worth digging further into.
| nicoty wrote:
| Oh interesting. I've recently tried learning JSCAD as I'm trying
| to model my freeline skates [(current progress here)](https://gis
| t.github.com/nothingnesses/dc1171c2e20f7a6d9a1cb9...). I like it
| as I'm already familiar with JS (one reason I opted for it
| instead of OpenSCAD) and I don't have to compile/install anything
| but my browser. However, I'm running into a limitation with it as
| it doesn't have a native function that allows me to bend models,
| so I'm currently trying to write one.
|
| Is it possible to bend models easily in DSLCAD? What would you
| say are some reasons why someone might use DSLCAD instead of
| JSCAD?
| dschroer wrote:
| From my understanding JSCAD is aiming to be 1:1 compatible with
| OpenSCAD. So both strengths and limitations will come with
| that.
|
| DSLCAD is a new take on the idea. Right now it doesn't support
| bending, however from my personal opinion, DSLCAD is simpler to
| develop for and should make it an easier platform to add
| bending support to.
|
| Feel free to add an issue asking for bending and we can hash
| out how to make it work. Getting the API down is often as hard
| or harder then implementing the solution.
| croes wrote:
| The link to the documentation page gives 404
| dschroer wrote:
| Should be fixed now. CI issue
| mvnuweucxqokii wrote:
| Years ago I came across this talk about a guy who built a Clojure
| wrapper around OpenSCAD in order to design his own keyboard.
| Potentially relevant:
|
| https://youtu.be/uk3A41U0iO4
| Cieric wrote:
| Loved the idea of the Dactyl Manuform when I first saw it,
| however in the act of trying to customize it to exactly what I
| needed/wanted I found the whole process convoluted and
| annoying. I understand the idea behind it now and might try and
| set my environment up to match his (since I didn't know he had
| a video on it.) But either way I can't see this as being a good
| solution to the problem.
| mk_stjames wrote:
| I wish there was a way to combine the power of an imperative
| language driven model generating language like this (that
| generates breps, NOT meshes like openscad) but with the initial
| modeling using a GUI like a standard CAD tool. The reason being,
| it is much, much faster to draw complex parts using traditional
| methods versus trying to 'program' them. Writing code is fine for
| basic shapes, but go and try an 'code' a complex ribbed casting
| with bezier-definied swept surfaces.
|
| I'd love to see a way to generate models with normal tools but,
| in the background, be able to access a code file that could then
| be embedded in an external script, headlessly. This way, say I
| have a part where 3 parameters change- I could take the code for
| that part, nest it in 3 for-loops, and iterate thru all the
| combinations of dimensions, procedurally generating the models
| (and potentially exporting them to a permanent format). FreeCAD
| allows actions to be scripted with Python but again, the actions
| have to be done in the language first- there is no 'going
| backward' from a part done in the GUI to Python (from what I can
| tell).
|
| This is what parmetric programs like NX, Catia, Solidworks have
| the ability to do via "design tables" or other internal tools.
| But even those tools don't have an easily portable 'language'
| that the models are portable in, and the kernels aren't something
| that you can get in and poke around with (or interface with, say,
| Python, which is my dream).
|
| Just food for thought for the author of this.
| speps wrote:
| See Houdini: https://www.sidefx.com/
|
| As a programmer, it's my favourite tool to make meshes. It's
| become a game studio standard over the last decade.
| mk_stjames wrote:
| Meshes are not CAD data. Engineering applications need math
| surfaces, and thus use Boundary Representation (brep) based
| models, not triangle meshes.
|
| This is the main difference between video games & vfx tols
| and engineering CAD tools and the reason why there is so
| little crossover in the software development of those tools.
|
| The author's tool here uses OpenCascade which is a true solid
| modeling brep kernel, hence my comments.
| nikki93 wrote:
| Does Grasshopper in Rhino count?
| mk_stjames wrote:
| Grasshopper can indeed drive NURBS surfaces in Rhino if I
| remember correctly, yes. But it suffers from the same
| problem I describe initially- you have to start with
| design from Grasshopper- it is a one-way-flow. There is
| no way to parametrically model something in Rhino and
| have it automatically generate a model graph that can
| then be reused.
|
| This is the main difference between tools like Rhino and
| the aforementioned parametric modelers (Autodesk
| Fusion360 is another fully parametric solid modeler that
| supports a 'tree' build with parameters that can then be
| changed at will at any time, and the model will rebuild).
| rcme wrote:
| What is the end result you want? If you're modeling by
| hand, why do you want to "program" the model later? What
| would that look like? What units would you operate on?
| What would the output be? etc.
| chaosite wrote:
| It's said that breps vs. meshes in 3D is like vector vs.
| raster in 2D.
| twelvechairs wrote:
| > Meshes are not CAD data...
|
| Meshes clearly are CAD data just they may be less useful in
| certain fields. CAD is broader than whatever form of
| engineering you practice
| roel_v wrote:
| This looks awesome. If the 'fillet' works, that'd be enough for
| me to switch from OpenSCAD. Although to be honest, having a
| utility library like BOSL would be necessary too, or at least
| some way to make threads.
|
| I'm going to download but another thing I would need to switch
| away from OpenSCAD - the ability to use an external editor, where
| the 3d model reloads correctly every time I save the program.
| Maybe your already has it, I'm going to check it out :)
| roel_v wrote:
| Oof I'm back already, this is quite rough.
|
| No editor included I see, that tripped me up for a second but
| it's IMO better than wasting your time on including one, once I
| got that it was fine.
|
| I tried to enter the smallest program I could think of:
| cube(x=10, y=10, z=10);
|
| but I couldn't get that to show anything. I can't resize the
| console it seems? So I'm not sure if there's an error on there.
| Either way, I'm not sure how I would go about finding out why
| I'm not seeing anything.
|
| 3d navigation seems wonky but maybe that's because there is no
| object yet? Sketchup has the same, it's no big deal, but I
| won't know until I can get something to render.
|
| Some quick wins:
|
| - draw axes in different colors and put a label on them - show
| scale markers on axes - add a minimal sample program, or some
| way to select a 'template' when doing 'new' that will provide a
| few samples - one minimal sample with a cube and a cylinder,
| one slightly more developed like the table in your screenshot,
| one that shows off each keyword/object. Maybe split across one
| for 2d, one for 3d. Or more as the library of functionality
| grows.
|
| More work:
|
| - Add a 3d navigation marker/tool like Blender has, that'll
| show where I'm looking at, and has 'zoom to all' function
|
| All of these would have helped in terms of 'getting started'.
|
| Apart from that - I'd first need to be able to at least render
| something to be able to say something useful :)
| virtualritz wrote:
| > No editor included I see, that tripped me up for a second
| but it's IMO better than wasting your time on including one
| [...]
|
| It's using egui for the UI so adding an editor (w. syntax
| highlighting for the custom language) should be very easy[1].
|
| [1] https://github.com/emilk/egui/blob/530e9f667c0969b09edb68
| f77...
| dschroer wrote:
| Interesting. I just tried your example and it worked on my
| end.
|
| Have you tried rendering any of the examples in the repo? I
| know its not ideal but just to see what is going on. Please
| add an issue on the repo so I can try to fix the issue you
| are experiencing.
| roel_v wrote:
| I just tried a few, but no difference. One problem is that
| I can't see how far I'm zoomed in or out, and opening
| another file doesn't seem to reset the camera. So maybe
| there is something outside of the view that I can't seem,
| although zooming in and out doesn't seem to help.
|
| I can open an issue but there isn't anything more than
| 'doesn't work' I can add. If you can describe some way for
| me to get information that's useful to debug, I can write
| that up.
| dschroer wrote:
| Having renders "auto focus" has been on my mind. Probably
| will be coming soon. I was focused on getting the
| language and runtime in better shape first.
| wlesieutre wrote:
| 3D software commonly calls this "zoom extents" to
| automatically pan/zoom so that the model fills a useful
| portion of the screen.
|
| In AutoCAD and Fusion 360 it's bound to double-click
| middle mouse because of how often it's used, though
| between users of 10 different 3D software packages you'll
| find 10 different but strongly held opinions on how the
| viewport navigation should work.
| dschroer wrote:
| It is designed for use with an external editor. It watches the
| files and hot reloads when you save changes. I didn't want to
| do a sub par job building my own text editor.
|
| I cant wait to hear about how it turns out for you.
| MrLeap wrote:
| I've made my own fully 3d lovecraftian text editor, I'd like
| to give this a try and see if I can make a 3d object for my
| text editor, with my text editor.
|
| Does it contain facilities for export into non-parametric
| mesh formats? (.obj / .fbx / collada..) np if not.
| dschroer wrote:
| Not yet. Its certainly something that I want to support. I
| want to avoid supporting all the formats so settling on a
| few clear options in the space is the goal. Right now its
| only STL since its super standard and doesn't force me to
| cover everything. I will likely move away from STL as
| things settle.
|
| Feel free to add a ticket requesting your favorite and I
| can look into moving to that format in the future.
| junon wrote:
| Exporting to OBJ would get you 90% of the way there. If
| you're not doing anything but generating a mesh, then OBJ
| -> whatever converters exist for pretty much every
| datatype.
|
| OBJ is also the easiest to implement, too. Assuming
| whatever geometry library you're using is using _real_
| geometry and not using any sort of weird volumetric
| rendering, etc. then it should be 'trivial' to export to
| OBJ.
| MrLeap wrote:
| Sure thing.
|
| I can still have fun with it in the meantime, if blender
| fails to export meshlab should succeed :p
|
| Very cool project
| levpopov wrote:
| Very cool, and excited to see more "Geometry as Code" tools
| getting built. In addition to comparing to OpenSCAD it'd also be
| awesome to see a comparison to CadQuery.
| AlbertoGP wrote:
| The inertial model rotation is a pleasure to use, I've done the
| same in some of my programs and while it feels a bit strange at
| first it does make it easier for me to perceive the shape as it
| moves.
| siemensikkema wrote:
| This reminds me of https://github.com/nicklockwood/ShapeScript
| although that is limited to Apple platforms.
| empressplay wrote:
| Great stuff! If you're interested in something similar with a
| simpler language (Logo) and relative model construction (using
| the turtle) check out turtleSpaces:
| https://turtlespaces.org/2021/09/08/how-to-create-and-3d-pri...
| You can export STL files and 3D print them. We'll be adding a
| multi-color export method soon
___________________________________________________________________
(page generated 2023-02-10 23:00 UTC)