Hacker News new | past | comments | ask | show | jobs | submit login
OpenJSCAD (openjscad.org)
209 points by lelf on March 12, 2020 | hide | past | favorite | 47 comments

Something I really want is the ability to write code to produce exact curves exportable via STEP, so I can get them into Fusion 360, which is what most CNC (e.g. the Shopbot PRS Alpha) prefers to consume. Imprecise polyhedra approximations are fine if you're 3D printing, but subtractive methods like CNC routers can do orders of magnitude smaller features. Bumping up the precision is just kicking the can down the road, also, most CAM software will just roll over and die if you give it shapes with massive polycounts, while it'll trivially handle the BRep version of the underlying shape (which might be a simple set of splines for example).

So far OpenCASCADE is the most promising library I've found. And it's been around for a long while: I don't remember the last time I had to tell bindgen about the "DECOSF1" macro!

And of course AutoCAD, but this is a hobby and I don't feel like spending thousands :-)

I have an issue with the third party CAM software we bought where it’s stuffing up the G-code in a way the OEM software doesn’t.

I create writing in Inkscape and save as DXF, then open in DraftSight, scale correctly, an other detail (outline, holes, etc).

Inkscape creates a DXF file with a whole lot of splines. The OEM CAM software is ok with this. The new third party app is creating overly complex G-code that causes our laser cutter to pause briefly at some of the end / beginning of the splines, which results in huge heat input and the stainless steel parts look terrible with small discolouration at the pauses.

I’m trying to find alternative methods of creating text, but I don’t know the space very well.

Maybe I need a different CAD or vector graphics app that can create letters with fewer objects?

AutoCAD has an explodetext command, but it creates completely useless outlines that look a mess. DraftSight’s same commsnd results in text outlines that are comprised of hundreds of small straight lines, also useless.

Any ideas?

Does the text retain its approximate shape if you use Inkscape's Simplify command to reduce the number of control points? And then does that actually affect the DXF output?

So, I've been sitting at my work computer for, what?, 4 years with QCAD and FreeCAD installed and have never thought to try either of these.

Going to give that a go today, just got to work at 05:40 so will let you know how I go later.

FYI, 05:40 is every hour.

Is this a reference to something? Not sure what you mean here.

Without a time zone the time of day is meaningless.

Have you tried cadquery [1]? It can do what you want and I think it's superiour to OpenSCAD in every way. It uses OpenCascade under the hood.

[1] https://github.com/CadQuery/cadquery

Just to add another tool to this discussion, I have had great success using Eyeshot by DevDept as a programmable CAD platform for .NET. Its closed source and a bit pricey but it was simpler and quicker to integrate with my commercial CAD/CAM product than OpenSCAD or an OpenCASCADE derivative and their support over the years has been responsive. They also include a STEP/IGES import export routine in their higher end offering. http://www.devdept.com

OpenSCAD is one of my favorite tools for building 3D printable things. I never could wrap my head around Blender or Solidworks, but OpenSCAD makes sense to me. It will be very interesting to see what it's like to work with it in a more familiar language.

Here's my most complex creation to date, a NASA spotlight/generator trailer to light up my LEGO Saturn V: https://www.thingiverse.com/thing:2758119

> It will be very interesting to see what it's like to work with it in a more familiar language [JavaScript?].

OpenJSCAD provide nothing more than much higher CPU consumption & heavy network traffic usage, comparing to 'native' OpenSCAD desktop app.

And for design complex 3D models modern web-browser and powerful PC is needed to use it comfortably.

But for fans of web-hosted/cloud apps OpenJSCAD, off course, is the real thing.

I love OpenSCAD for everything but the language, which is .. so bad that the rant stays corked.

Perhaps the 3MF https://github.com/3MFConsortium output format could be useful too?

Edit: ah, i didn't see any dates; but I do see a "Google+ community" link ... Perhaps there's more to be done to make this a viable alternative.

Looks like the last commit was in April of 2019.

EDIT: There's a giant V2 branch with newer updates and updated links to their new community. I am not sure they realize how dead the project looks with no commits to master since 2019 and Google+ links on their homepage and readme.

Does V2 support STEP output? As a semi-professional (i.e., an engineer, but not a mechanical engineer, using this for work purposes that aren't 3D printing), anything that does not support STEP is simply useless to me.

Curious, what do you dislike about it?

I used it for a project recently and found it to be really nice and expressive. I love that it's got a functional feel but you can do loops and compose modules in a really powerful way.

I used OpenScad a few years ago and was also initially horrified by the language until someone pointed to me the "nightly build" versions which supported the functional feel and compositions that I think you are describing. Those made a world of difference for me. I wonder if the parent is referring to a really old version (many Linux distributions still ship those). Just a guess.

Yes. I built a project using the 2015 release. ugh.


Ah that might explain it. I picked it up recently from scratch using the nightly build (via snap) so I'm not aware of the history of the language.

The old version language was bad to the extent that after playing with the tool for a few hours my thought was "why did you cripple such a good idea with such a bad language"??? I seriously considered digging out the Dragon Book to write a better language front end to it.

For me, the syntax is ok, however it doesn't always do what you expect. For example:

    if (some_condition) {
        x = 2;
x doesn't get set to 2. Or even better, this:

    x = 2;
    echo("x = ", x);
    x = 5;
This prints out that x = 5.

It is not an imperative language even though it is dressed up like one. You are describing a data structure, not a sequence of operations.

It should technically throw an error before compiling. You're thinking about it as an imperative language, when it aspires to be declarative.

Personally I think that's a bug, not a feature. If the language aspires to be declarative, but features imperative constructs, it should have a syntax that reflects the distinction.

I work with these kinds of things a lot, having that clear divide between declarative and imperative operations on whatever being expressed isn't only easier to learn and read, it's far more expressive and powerful for complex systems.

You misinterpret--or rather, I wasn't clear. While I say it aspires, I'm not saying it's a good choice.

I'm just saying its odd behavior makes a lot more sense once you know it's meant to be declarative, and you can make a lot more headway when working with it.

Not OP, but :

- you can't store objects in variables, so code looks convoluted with deep nesting as you need to apply multiple transforms to objects

- there are no real variables, more like constants that take the value of the last assignment, so you can't do basic stuff like x = min(x, 5)

- you can't access object attributes (size, etc.) so it's not possible to generate features that depend on another object. You always need to have lots of parameters in scope. A simple use case would be to punch 4 holes in the corners of a box cover.

- string functions are very limited, there is only str() to convert a value to string but with no control on the formatting, there is no printf-equivalent

I'm able to do some of these things. Someone else said that perhaps the nightly build is different?

``` module thing(x) { cylinder(r=x,h=10); }

translate([10,0,0]) thing(5); x = min(4,2) + 1; translate([-10,0,0]) thing(x); ```

works for me.

Your third and fourth points are good ones. I think the first two points are mitigated by using functions and modules correctly.

The syntax looks like C but it's not, and causes bugs, e.g. in this loop:

  i =0;
  for (j = [1:5]){
keeps printing "1" instead of 0 to 4

I actually really like the OpenSCAD language; I've even started to prefer OpenSCAD to Fusion360 for sketching ideas in recent years.

It is very easy to import modules for operations like threaded holes or gear teeth, and it feels very familiar if you are coming from a graphical CAD tool like Inventor or SolidWorks because it follows the same process of generating parts from a nested series of elementary operations. I've never felt frustrated trying to write parts, but to be fair, I also don't use it for serious manufacturing.

There is an attempt to be able to write it in clojure.


Haven't tried it but enjoyed this talk (about 3d printing ergonomic keyboards using the above): https://www.youtube.com/watch?v=uk3A41U0iO4

Programming is my day job, so being able to think of solid objects in terms of code just makes sense to me. I find myself using OpenSCAD more and more just for sketching out ideas, and experimenting with shapes that would be hard to make using traditional CAD.

I dream of a day when parametric CAD is bundled with a usable package library. Being able to `import` versioned parts would be a huge upgrade, and would lead to the development of better standard libraries.

There are also some land mines around the rendering process, e.g. shapes that render just fine as a preview, but will crash the CGAL renderer. I’ve also had the opposite happen. It seems like there’s room to add better validation (or maybe a way of automatically simplifying ASTs?) before they hit the renderer.

CadQuery (python lib that wraps freecad's CAD kernel) is a bit more similar to a traditional CAD system in terms of how it constructs parts (workplane, etc).

Also, onshape.com (commercial with hobby free tier) has a scripting interface that i believe is js-like (i have not yet had to use it, but i use onshape quite a bit for hobby projects). Their versioning and importing of community parametric parts is pretty tight imo.

OnShape uses Parasolid (best-in-class geometry kernel used by a LOT of different commercial CAD products) under the hood so if you are trying to make a manufacturing quality part it will stand you in good stead.

OpenCASCADE (FreeCAD's kernel) is pretty good too.

no, CadQuery is a wrapper on top of PythonOCC

Same thing

You can do functionally defined implicit modeling in http://ntopology.com

PythonOCC [1] wraps the OpenCASCADE kernel and is easily installed through conda:

conda install -c dlr-sc pythonocc-core=7.4.0

[1] https://github.com/tpaviot/pythonocc-core

The great grandmama system is BRLcad. And she’s still dancing.


OpenSCAD uses CGAL which allows for exact definitions for the rendered-out objects (as opposed to floating-point-inaccurate results; often observed as e.g. flickering coincident planes in OpenSCAD's non-CGAL OpenGL preview).

What does OpenJSCAD used as internal geometric representation?

Is it also exact?

It uses csg.js

Unfortunately its GitHub is not ... expansive about its innards. It says "this library implements CSG operations on meshes..." which I assume means it is NOT operating on a parametrized boundary representation like the industrial-strength CAD kernels (Parasolid, OpenCASCADE, CGAL).

I would be very careful about using models generated in OpenJSCAD to manufacture anything (this is one area where proper handling of topology and degeneracy is critical).

Wait: whenever I've used OpenSCAD I get polyhedral approximations, not actual spheres/cylinders/etc. You can pump up the resolution but that quickly kills performance and obviously doesn't solve the underlying issue. How can I get OpenSCAD to do e.g. actual BRep? (Ideally in a way I can export to other CAD/CAM software?)

FreeCAD (which uses OpenCASCADE under the hood) can open OpenSCAD CSG files. This should get you a BRep

Another neat-looking project. I spend much of my time in FreeCAD which has a very high learning curve, but is fully scriptable in Python. It's effectively a UI over a programmatic interface to construct multicomponent documents which include surfaces, CSG, etc, etc.

You can also use OpenSCAD from inside FreeCAD. I do it all the time. They both play together well.

How do you apply live edits? I tried to change one of the sizes and nothing happened at first.

It looks like several minutes later one of my changes took effect - is the site getting hugged to death? Does parsing and rendering not occur on the client side?

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact