8 ms·
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.
- croes 4y agoThe link to the documentation page gives 404
- dschroer 4y agoShould be fixed now. CI issue
- mkeeter 4y agoCan 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 4y agoIt's using open cascade.
- levpopov 4y agoVery 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.
- h2odragon 4y agoI 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.
- dschroer 4y agoThanks for the suggestion. Ill see what I can add to make it clear.
- cjbgkagh 4y agoIIRC 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 4y agoA 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 4y agoWell, 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 4y agoBe 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.
- roel_v 4y agoThis 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 :)
- dschroer 4y agoIt 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 4y agoI'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 4y agoNot 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.
- MrLeap 4y agoSure thing. I can still have fun with it in the meantime, if blender fails to export meshlab should succeed :p Very cool project
- 4y ago
- digdugdirk 4y agoVery 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.
- TkTech 4y agoIt's using open cascade.
- dschroer 4y agoIts 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).
- junon 4y agoYour LICENSE file is misspelled, by the way.
- mvnuweucxqokii 4y agoYears 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 https://youtu.be/uk3A41U0iO4
- Cieric 4y agoLoved 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.
- zellyn 4y agoIt 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 4y agoI 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 4y agoOh interesting. I've recently tried learning JSCAD as I'm trying to model my freeline skates [(current progress here)](https://gist.github.com/nothingnesses/dc1171c2e20f7a6d9a1cb97654497c55 https://gist.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 4y agoFrom 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.
- TheDesolate0 4y ago[dead]
- gfodor 4y agoIf you like the idea of a "markdown for 3D models", you should definitely check out Smooth Voxels: https://svox.glitch.me/ 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 https://github.com/webspace-sdk/smoothvoxels
- AlbertoGP 4y agoThe 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.
- empressplay 4y agoGreat 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-print-a-chess-pawn-in-turtlespaces-logo/ 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
- mk_stjames 4y agoI 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 4y agoSee Houdini: https://www.sidefx.com/ 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 4y agoMeshes 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.
- trehans 4y agoThis 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 4y agoHey. 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 4y agoThanks 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!
- dschroer 4y agoFor sure I would accept a PR! One of the goals I have here is to try and make it approachable to expand for others. If you have an idea on how to make this work please feel free to work on it. To save time up front I would suggest doing a bit of design work. Feel free to make an issue and post things like example code snippets of how you would like to see this work. We can work together to make this feature a reality.
- loa_in_ 4y agoSee 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/ http://www.povray.org/ https://github.com/cyborg5/pov2mesh https://github.com/cyborg5/pov2mesh
- dTal 4y agoIt couldn't; POV-Ray outputs images, not meshes or CAD models. It is purely a graphics tool.
- naasking 4y agoThe project page says it outputs a triangle mesh. POV-Ray would have to have a notion of volumes and surfaces in order to calculate shadows and reflections.
- dTal 4y agoI'm afraid you are mistaken. It does not output a triangle mesh, and the project page says no such thing. It does not even construct such a mesh internally. Its "notion of volumes and surfaces" is implicit and constrained to ray intersection tests for graphics rendering. There is a news entry [0] pointing to a blog post [1] by someone who did manage to sort of reconstruct a triangle mesh from a POV-Ray scene. They had to write macros to shoot a bunch of depth test rays into the scene to generate a point cloud, and extract the surface in Meshlab. They've released some of the code [2] and it's called "pov2mesh". If you read any of that - or use POV-Ray at all - it's very clear that it's not a mesh editor, or any sort of CAD tool. [0] http://www.povray.org/news/index.php#324 http://www.povray.org/news/index.php#324 [1] http://graphics.cyborg5.com/2016/10/29/converting-pov-ray-shapes-to-triangle-mesh-for-3-d-printing/ http://graphics.cyborg5.com/2016/10/29/converting-pov-ray-sh... [2] https://github.com/cyborg5/pov2mesh https://github.com/cyborg5/pov2mesh
- naasking 4y agoThe link [0] literally says: > #pov2mesh A Set of Macros in POV-Ray Language to Convert a POV-Ray to a Triangle Mesh I never said it was a mesh editor or CAD tool or anything else except that it would need an internal representation of volumes and surfaces in a scene, and that the OP linked to a tool that generated a triangle mesh from this info. [0] https://github.com/cyborg5/pov2mesh https://github.com/cyborg5/pov2mesh
- dTal 4y agoThis 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 4y agoThanks 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 4y agoHere 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 https://github.com/hannobraun/Fornjot [2] https://rhai.rs/ https://rhai.rs/
- hannobraun 4y agoHey, author of Fornjot here. Rust was chosen as a modeling language for two reasons: 1. Since the whole project is written in Rust, it was the most straight-forward choice. No dealing with bindings to another language or a scripting language runtime for the time being. 2. To provide an interesting alternative. I suspect that there can be a nice niche for Rust, creating infrastructure for writing models (e.g. libraries for generating screw threads, that kind of stuff). I don't think that Rust is a great language for defining CAD models. Long-term, I suspect that the preferred choice for Fornjot will be something else. But for the time being, this decision allows me to focus on the CAD kernel. > There also seems to be a goal overlap between Fornjot and DieselCAD Do you have a link for DieselCAD? Searching on Google only got me car results.
- siemensikkema 4y agoThis reminds me of https://github.com/nicklockwood/ShapeScript https://github.com/nicklockwood/ShapeScript although that is limited to Apple platforms.
- zem 4y agoquick 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.
- dschroer 4y agoYou are probably right. The Linux hacker in me still kind of prefers having a bit of style to names. Maybe over time this will change.
- mk_stjames 4y agoIf you haven't seen it you may want to check out https://github.com/zalo/CascadeStudio 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.
- rcarmo 4y agoChamfer and fillet are awesome, but the pipe… mixed feelings, especially since it uses a dash. Either a normal pipe or an Ocaml-like |> would feel more natural.
- dschroer 4y agoThe goal of pipe is to allow the code to read top to bottom. I always found it hard to explain the way an OpenSCAD program reads upwards when nesting operations. As for the syntax there are certainly a lot of ways it could feel. JS devs would likely be familiar with =>, F# and Ocaml |>, Java ->. In the end I just picked one that felt natural to type for myself. From my experience if you write in enough languages you develop the ability to switch as needed.
- pvillano 4y agoThis might be the right thread to ask for help with a 3d problem I've been working on for a year or so. I have a resin 3D printer, and I want to make handles for it. Specifically, ultra lightweight handles using an irregular lattice. OpenSCAD chokes on trying to union 100s of cylinders. Real tools cost $1,000s. Right now it looks like I'll have to write something to do the union in voxel space
- OJFord 4y agoFor work or hobby? Fusion360 doesn't cost a penny for the latter. (I'd love to use code or FreeCAD or ideally FreeCAD stored as sane human readable code, but none of the options are quite what I imagine.)
- deleted 4y ago[deleted]
- pvg 4y agoIt's not really because Show HN is specifically for people showcasing their work and getting feedback. But there are lots of other kinds of threads where it might fit up to an including posting an Ask HN of your own.
- noncoml 4y ago1. FreeCAD. I am not 100% sure what you are trying to do, but FreeCAD most probably con do it. And the forum is there to help you if needed. 2. 3DExperience Solidworks for Makers. It's something like $100/year.
- elromulous 4y agoI'll have to check this out. Really great to see more of "cad as code". My current favorite is cadquery. It's pretty neat in that it simply is python. https://github.com/CadQuery/cadquery https://github.com/CadQuery/cadquery
- WillAdams 4y agoWould writing out text files be an option? I've been trying to do this from OpenSCAD (now using RapCAD) and while I sort of have it working: https://github.com/WillAdams/gcodepreview https://github.com/WillAdams/gcodepreview I'm not so far along that I wouldn't try something else.
- dschroer 4y agoYou have a super interesting use case. Can you reach out on the github issues so that we can track it? From what I can tell you are trying to generate GCode directly from the software is that the case?
- WillAdams 4y agoYes, that's it exactly --- basically trying to avoid the need for additional CAM software and provide complete and total control over machine movement.
- qualudeheart 4y agoThis is very cool. Do you use Github Sponsors so I can tip you?