In a world of CAD packages with arcane or unfriendly interfaces there’s a stand-out player that’s remarkable because it has no interface. OpenSCAD is a CAD package for coders, in which all design elements are created in a scripting language rather than graphically. It’s maybe not for everyone but it has a significant following, and its reach has been extended further as you can now run it from within a modern web browser.
The origins of this project can be tracked back to August of 2021, when when Autodrop3D’s [mmiscool] offered a sizable bounty for anyone willing to port the parametric CAD modeler to web assembly. Developer [Dominick Schroer] ultimately answered the call with openscad-wasm, which implements the core of OpenSCAD as a JavaScript ES6 module. From there, it just needed to get paired with a user interface, and off to the cloud we go.
Opening it up and giving it a go, we found it to be a very usable OpenSCAD version, albeit a little slower to render than the desktop equivalent on a mediocre laptop. We didn’t try exporting and printing an STL, but so far it has given us no reason to believe it wouldn’t be every bit as useful as the version you’re used to.
But wait, there’s more! Parallel to this effort, [Olivier Chafik] has also been working on his own idea of what OpenSCAD in the web should be. He’s using the same core developed by [Dominick], but has combined it with the Monaco editor from Microsoft and a Javascript STL viewer. Despite being very similar, we’re happy to report there’s no rivalry here; in fact, according to the video after the break, it sounds like two the projects have already swapped a bit of code.
The move among desktop applications to move into the browser and often into a pay-to-play cloud has seemed relentless over recent years, so it’s pleasing to see a rare example of a browser migration that’s open-source. It has the handy effect of bringing the CAD package to platforms such as tablets or Chromebooks which wouldn’t normally be an OpenSCAD platform, and this we like, a lot.
Welcome to the new, better world. Yours is gone. Future is now old man. /s
Ok IBM, Hahahaha hahaha hahahahahahaha ha haha hahahaha hahaha haha haha ha….
Sarcasm aside, it’s is a new world but yeah, it’s not a better one.
Not to be confused with OpenJSCAD / JSCAD (https://github.com/jscad/OpenJSCAD.org) which is a web interface (& CLI) clone of OpenSCAD that uses JavaScript syntax. Which is in a repository named OpenJSCAD.org for a project named JSCAD that’s hosted on the openjscad.xyz domain.
Nor ScriptCAD (https://scriptcad.org/) which is a web interface that uses JavaScript made to look like OpenSCAD syntax.
Nor SCAD-JS (https://github.com/scad-js/scad-js) which uses JavaScript syntax and compiles into OpenSCAD syntax to be used by OpenSCAD.
Nor openscad-openjscad-translator (https://github.com/jscad/openscad-openjscad-translator) which takes OpenSCAD syntax and compiles into OpenJSCAD syntax to be used by JSCAD.
ScriptCAD actually looks nice. The non-native interface is a sticking point because it’s sluggish but it looks neat!
I did ScriptCAD but haven’t developed it further as the underlying CSG operations are slow and therefore any kind of serious designing is slow even though I added very basic caching. I discovered ZenCad (Python with PyOCC/OpenCASCADE) and past weeks coded a OpenSCAD like layer on top of it, still Python though.
ZenCad is a good start but it needs more development to have API as close as possible to OpenSCAD as I like to memorize one set of API. While I extended it as “OpenZCAD” (my working title) I realized to abstract it more, and added Fogleman’s SDF (Signed Distance Field) and LibFive backends aside of PyOCC/OpenCASCADE geometry engine – essentially having three backends of choice, each with its strengths; for now just a few methods work like basic solids and linear/rotate_extrude etc; as soon it has matured more I might publish it on github. I even use OpenZCAD as a library right now coding non-planar slicer, indicating how worthwhile proper abstraction pays off and common API.
But to be honest, OpenSCAD problem isn’t the language itself, it’s CGAL, the geometry engine at the core. Since 6+ years there is a bounty to export colors to final .stl, .off or whatever, and it’s not claimed – why? Because OpenSCAD is CGAL fused and cursed by it, so far nobody found a way to carry over the metadata of the objects to the final triangles/faces to be exported (it’s surely it’s doable, but a pain to implement).
What we (as community) need is a stable API, a basic language like OpenSCAD or something basic in Python – and then adapt multiple backends computing those descriptions. OpenSCAD biggest advantage is the fast preview, doing all CSG ops in OpenGL with the Goldfeather algo – this is why OpenSCAD is still used, also by me. I even use OpenSCAD as Gcode simulator, or testing new slicing algorithms, it’s a “programmable geometry viewer” for me; I code in Python and write .scad files and view geometry with ‘openscad’ just as “viewer”.
What I can tell, PyOCC/OpenCASCADE does perform better speed-wise and accuracy at CSG ops, much better than CGAL, but OpenSCAD preview mode still beats all other alternatives.
Another advantage of OpenSCAD is . . . the extremely worthwhile libraries, NopSCADlib or BOSL2, alone for those two libraries it’s worth to make YACC/LEX importer for Python-based solution. In a way we need to look at OpenSCAD as a language, a high level language to describe geometries (and .csg as intermediary file format) – and get away to look at OpenSCAD as a program alone, in a way ‘openscad’ is a reference implementation of “OpenSCAD” language.
So, the dream team or combo is this:
– performing CSG in OpenGL via Goldfeather algo in preview mode
– represent geometry in pure form (not tesselated or triangulated), only at export level perform what’s needed
– multiple backends (OpenCASCADE, Folgeman’s SDF, LibFive, CGAL)
– OpenSCAD’s “include” and “use” support (.scad parser)
Did you publish your OpenZCad work anywhere? I’d be interested to have a look…
I think this is what he was talking about.
https://xyzdims.com/3d-printing/enochslicer/
https://openjscad.com/ is again available, and very recommended.
Thanks for the overview – that’s handy :)
Implicitcad, written in Haskell, looks very nice, particularly for rounding and fillets. There used to be a test site but it is down at the moment. It seem(ed) like a promising direction.
“OpenSCAD is a CAD package for coders”
Is it though?
Sure, that’s the common thought on the topic. It looks like code, it feels like code, it’s for coders. But OpenSCAD is missing some pretty important features that most programming languages have and when anyone asks about this on their forums the answer is invariably that OpenSCAD is NOT a programming language and that making it one would unnecessarily make it more complicated for non-programmers to use.
What non-programmers?
As such I can’t figure out what audience OpenSCAD is actually intended for. As code-like as it is it certainly scares off potential non-programmer users. But as a programmer who uses it I find that the limitations really do get in the way a lot.
Variables are not true variables. Basically, whatever the last value a variable gets set to, that’s computed first and it has that value much like a constant as the entire shape is produced. There are exceptions like special variables, for-loop iterators, and the let() statement but that’s the general idea.
Functions are functions in the mathematical sense. You can’t really have separate execution steps or states inside a function. Modules can but modules don’t return values. As a result functions end up being long chains of ternary statements that look like spaghetti code unless you configure your text editor to treat parenthesis as blocks, the same as braces. Functions often end up requiring being split into intermediate functions, which may need to be called multiple times on the same data since there is no way within a function to store the output. Recursion becomes commonly necessary as well.
If you can manage to write what you need as a function which is tail recursive OpenSCAD might recognize this and behind the scenes replace the recursion with an iterator. But these are cases where in a “real” programming language one could have just used a for-loop! That would be so much easier! If you can’t get your function into a tail-recursive form then calling it against any data which causes too many levels of recursion fills the stack and crashes.
And then, with no classes, namespaces or anything like that all those intermediate function names pollute the global namespace. Want to write a library of useful OpenSCAD shapes? Want to consume one? More to the point, want to consume more than one? You had better hope no two libraries use the same module or function names! If they do it just won’t work!
Why would I run into these kinds of problems when all I’m trying to do is generate a shape to 3d print rather than write an interactive program?
One positive thing that sets OpenSCAD apart is it’s customizer window. I really doubt that very many non-programmers are going to write their own OpenSCAD objects but a programmer can create one and give it all sorts of customization options that the end user can tweak in the customizer menu. Used well an OpenSCAD script can be thought of as a design generator, not just a mere static object design. Aka… a program!
One thing I like to make customizable is screw sizes. For all the advantages of the metric system, they don’t really matter when you walk into a US hardware store on a budget! it’s nice to be able to use the screws you have on hand.
I’ve had to write various string and vector functions, things that are built in to most languages and really easy to implement in most others. Wow, what a pain in the 4ss! The idea is to be able to take a fastener size in string form such as M3, #6 or 1/4″, chose a lookup table based on M, # or “, parse the rest as a number and lookup various fastener dimensions. That would be SO easy in any other “language”!
I’ve been looking into alternatives. OpenJSCAD or JSCAD or whatever they are calling it today looked good but had this funky web based UI where you had to drag all applicable files into the window (remember, I am into the library idea). It only seemed to partly work depending on what browser one used. On some browsers it could only ever work with a single file. On others multiple files worked but it didn’t update itself when you save changes to the file, you had to manually re-load everything each change. On no browser did both multi-file and auto-reload work. Now they have a new name, new UI that I’m not sure how to use plus they seem to have changed the syntax somewhat. Or at least the examples are all coded differently, now they do that weird declaring functions as constant function pointer thing… I don’t know. It doesn’t look stable. I’d be afraid of learning it only for everything to change again.
There’s CadQuery but it’s all containerized and requires pulling in a whole separate Python environment just for it. Yuck!
I recently ran into RapCad. It’s a lot like OpenSCAD but has some of those limitations fixed, it has real variables and supports imperative user functions. That sounds like quite an improvement although still no classes so including multiple libraries written by multiple authors still might be problematic.
And with any of these alternatives there seems to be a lot less community out there using them. I imagine building up experience and a good library of tools in one of these languages only for developers to lose interest and move on. Nobody seems to have the market share of code-based cad like OpenSCAD does.
Yes. It’s not a Turing-complete language. This is not the point.
It’s a CAD package for coders because if you’re used to code, you’ll be right at home with OpenSCAD.
No need to be a 1337-level coder though, after all I use OpenSCAD and I’m not up for much beyons scripting languages.
1. OpenSCAD surely is Turing-complete (abstracting from memory limits). It would be pretty easy to simulate a single-tape system with recursion.
2. OpenSCAD is basically a *functional* programming language (like Haskell, but much more limited). This means that variables and functions are like in math: variables have what values they do, functions always return the same value almost without any side-effects (the only side-effects I can think of is echo(), which is mostly for debugging), and modules do the same thing each time you call them with the same arguments. This allows the system to cache outputs, so if you call a computation-heavy module several times with the same arguments (e.g., to generate a subpart in multiple places), OpenSCAD only has to execute the module once (I don’t know how aggressive OpenSCAD is about doing that). Using a functional language has a significant learning curve for those of us more used to imperative programming, but it’s kind of cool in that it makes you think about the programming task in new ways. There is a kind of elegance to doing things with recursion that one is used to doing with loops. That said, last I checked, the tail-recursion was a bit more limited than I liked (I don’t think you can use let() with the tail clause).
3. I think the main real limitation in OpenSCAD is that functions and modules are not objects: you can’t assign them to variables or pass them to other functions or modules. The child() functionality lets you get around that in some cases. And to get around the impossibility of passing a function, I ended up writing a function parser in OpenSCAD ( https://www.thingiverse.com/thing:2295309 ) which parses non-recursive OpenSCAD expressions in string frmat like “y == 2 ? pow(x,2)+cos(x) : y*x” so you can pass them to functions and modules (you can compile to an intermediate representation, so it’s not as slow to use as you might fear). It’s still limiting not to be able to pass a general function, but for most use cases (e.g., fitting text to an arbitrary mathematically described shape) it’s good enough.
Yes, functional programming.
Basically throwing everything Computer Science has learned since splitting from mathematics in the trash in order to make mathematicians feel at home.
Try this:
Write a substring function using purely functional programming with no side-effects.
Got it? Good.
Now count how many times it is calling the len() function and re-counting the size of your string. Wouldn’t it be nice to do that once and store it in a local variable?
And then consider that supposedly the excuse for the limitation is that it wasn’t supposed to take an experienced coder to use this language. Tail recursion? Really?
I mean, I get the idea that it can be fun to be made to think about the problem in a different way. No doubt it’s a healthy mental excercise. But it kind of flies in the face of being meant for beginner, non “1337-level” as Jenny put it coders AND at the same time of being familiar to most coders.
I guess maybe the audience if Haskell fans with 3d printers?
Probably it’s not a coincidence that I am a mathematician. :-)
I am not saying that OpenSCAD is great. But it is fun and I’ve found it growing on me over the years. Speaking philosophically (I’m also a philosopher), we might divide computer languages into ones where we think in terms of doing and ones where we think in terms of describing. On the “doing” something, we have imperative languages. On the “describing” side, we have things like functional languages (describing a function or an object), regular expressions, and hardware description languages. Moving from doing to decribing does indeed require a significant mental shift.
I just looked at the _substr() definition from my expression evaluator code:
function _substr(s, start=0, stop=undef, soFar = “”) =
start >= (stop==undef ? len(s) : stop) ? soFar :
_substr(s, start=start+1, stop=stop, soFar=str(soFar, s[start]));
It is true that it calls len() once par substring character if you don’t specify the stop parameter. But I assume that calling len on a string is just getting the value of some field in the string object, and so it’s pretty fast. If I wanted to, I could reduce the number of len() calls to 1 by having a wrapper function that does the precalculation of the length and calls a function that requires the stop parameter to be filled in. It’s a common pattern in OpenSCAD for me to have a caller-friendly function that does some pre-calculations and calls another function.
You can also get some of the functionality of changing variables by using let() (like Haskell let or where).
I have no idea how friendly OpenSCAD would be for someone who has very little coding experience. My feeling is that for the simplest things–joining a few shapes or having a few booleans–it’s about as simple as can be, at least for those of us uncomfortable with GUI approaches to 3D. But then as things get more complicated for those of us (including myself) who are more familiar with imperative paradigms, something else would be better.
I admit, I have very limited experience with functional languages. But my common sense would tell me that len() is a common subexpression which – in a functional language – should be computed only once by the runtime.
I have used OpenSCAD a lot, and I love it, but I recently released my own open source computational geometry library to address several deficiencies I saw. Perhaps some of you would be interested. I hope someday it might power OpenSCAD and/or have similar interfaces built on top of it. I’m looking for collaborators. It has an API very much inspired by OpenSCAD’s, but it’s all C++ (and GPU accelerated), so no need for a custom language. https://github.com/elalish/manifold
OpenSCAD has recently introduced first class functions
https://en.wikibooks.org/wiki/OpenSCAD_User_Manual/User-Defined_Functions_and_Modules#Function_Literals
Hopefully it will someday soon also incorporate first class modules
https://github.com/kwikius/openscad/blob/module_literal_v2/examples/ModuleLiterals/extrusions2d.scad
Yeah. That sounds like what the OpenSCAD people say on the forums. But if the idea is to build a future where more average people are designing and printing more household items themselves one is going to want lots of re-usable shared libraries of pre-designed and configurable components. And designs need to be more parametric which means thinking more like writing a program to generate a design than simply drawing a static picture of a part. These limitations make that so hard and so messy. Making it a bit more complete isn’t going to make it require a “1337-level” coder.
I mean really, how many times does the conical indent and cylindrical shaft of a countersunk bolt need to be re-invented? Or the mounting hole of a common hobbyist switch? IEEE standard Power jack? Tapered heat-set insert, etc…
use
use
bolt = new fastenerlib.countersunk(bolt_size_set_in_customizer);
difference(){
main_body();
bolt.draw();
vitamins.rockerSwitch.draw();
vitamins.powerJack.draw();
}
Plenty of more complete languages get used by people that don’t consider themselves to be coders today. How many “scripting languages” don’t have variables? Or imperative functions? Even BASIC was a lot better in this regard than OpenSCAD!
Do you ever code an Arduino sketch? That’s meant to be easy for beginners right? And it is full of object oriented libraries. There’s even a package manager for installing them built right into the UI!
It’s not like I’m asking for pointers and direct memory access. Just adding imperative functions, real variables and classes would make it pretty much perfect.
Besides, is it really easier to explain to a new, non-coder how variables work in OpenSCAD vs in a “real” programming language?
>> I told it to make that box X wide, and see here, X is set to 3. Why is it so big?
>Well look down there, several lines later in this totally unrelated part of the file you set x to 6.
>>But that was after.
>There is no after in OpenSCAD.
>>Wait, what?
>It’s for simplicity! In OpenSCAD there is no concept of “time”. Because you aren’t supposed to have to think like a “1337-level” coder to use it. And only “1337-level” coders experience the concept of time or cause always preceding effect as part of every day life.
Come on, that’s not easier!
And really. Would you rather try to explain to a beginner how to use a built-in string function, how to implement that string function as a for-loop or how to implement it with tail recursion? Seriously, I think tail recursion is a concept we learned in Computer Science II, then NEVER had a need to use again in class, professionally or in casual scripting because there is ALWAYS a better way to accomplish the same goal with a much simpler to understand and more efficient to execute loop. Except.. in OpenSCAD.
So, as a coder I would say yes, initially I felt right at home with OpenSCAD. But in the words of Admiral Akbar, “IT’S A TRAP”. As soon as one scratches past the surface it stops feeling like home. Instead it is a very foreign place that makes one look at simple, common tasks in totally foreign and more complicated ways.
You have a really long and drawn out way of saying “This software isn’t for me”. It’s pretty obvious that many people are happy with OpenSCAD in it’s current form, so why not just let them use it without trying to convince them they are wrong?
Short answer, Because OpenSCAD already has a near monopoly on the community. I’m not interested in working alone on things only I will ever use. Plus, it does have a lot of really great stuff going for it, just a few features away from being really great and adding them shouldn’t break anything for anyone who likes it as/is.
I wrote a long answer but apparently in the wrong box.
OpenJSCAD is indeed changing and the new syntax you mention is just moving along with javascript to be able to work as nodejs cli apps as well as use web based ui.
The dev team in openjscad is small, people come and go, so this get developed at different pace during the years.
feel free to join discord if you are interested in jscad.
https://discord.gg/AaqGskur93
I am working an a new jsacad prototype that currently runs both in browser and can be started as desktop app.
the issues with multiple file projects, and reload is something was improved.
I welcome any interested in coding cad, that also like javascript to try jscad, and report issues, we need a bigger community of users and hopefuly in time few more contributors.
I really enjoy OpenJSCAD. It’s fast, it’s easy, and there are so many excellent Javascript libraries I can just paste in.
Maybe down the road. I started switching to OpenJSCAD a while ago but when I found it had changed and my code didn’t run any more I went back to OpenSCAD. Now I’m a lot farther into my current project and don’t want to start over but maybe after that…
It’s not a programming language like everyone is used to, it’s a hardware description language. Its purposes are a lot more like that of VHDL or Verilog than C or Python. ONOZ no variables? That’s because you don’t use time to describe a static object, so the idea of something changing over time is out of place. It’s more akin to shape decomposition in art than defining a precise sequence of steps.
Off the cuff, let’s describe making a table in English and OpenSCAD: It’s made by adding together a box that’s X wide, Y long, Z thick, and four cylindrical legs with a diameter of D and height H on top, each one shifted two Ds away from each corner of the box. Then take a step back and flip the whole thing over (because who doesn’t want to flip tables) and ta-dah.
rotate([180,0,0]) Union(){
cube([X,Y,Z]);
translate([2*D, 2*D, Z]) cylinder(d=D, h=H);
translate([X-(2*D), 2*D, Z]) cylinder(d=D, h=H);
translate([2*D, Y-(2*D), Z]) cylinder(d=D, h=H);
translate([X-(2*D), Y-(2*D), Z]) cylinder(d=D, h=H);
}
With the exception of the whole PEMDAS thing needed when flipping it over (which is just for fun or for analogy to physically building a table), it reads friggen close to the English. Haven’t written any OpenSCAD code in years and I’m doing it from memory so no clue if it works, but it ought to.
OpenSCAD is a phenomenal teaching tool too – breaking things down into smaller chunks which are easier to describe, doing so with mathematical precision/concepts and attention to syntax.
Yeah, I reach for Fusion nowadays, and I still think FreeCAD is a better project, but OpenSCAD has some unique value to it and I’m glad to see it’s far from dead.
Fork it.
I think the best way to think about OpenSCAD is like a 3d version of SVG. SVG is a human readable 2d vector object description language, but our isn’t a programming language. If you want programmatic SVG, you wie code in n some other language like Javascript or PHP to generate the correct SVG code, or change the elements that already exist.
This is probably why most odd the existing web implementations may it to Javascript.
I’m grateful that true “Coders” find it lacking. As a ‘C’ hacker from the 1980’s I find its perfect. Its simple enough for me to use. Its complicated enough that if I need a new method I can easily add my own. Or include one written by someone else.
You may run it from the command line. You may embed it in your own application. And now you can run it from your Chromebook.
I’ve programmed it to create a part using a bezier curve. And I’ve even “programmed” it to generate my part and the gcode needed to run the part on my CNC.
I wouldn’t change a thing.
I really wish OpenSCAD supported parametric 2D line drawings, still not found anything to use for that.
Try Freecad, see simple demo here –> https://www.youtube.com/watch?v=VK1oqqI88tk
You can build polygons, even vertex by vertex… and it’s an absolute pain. I have built a set of functions to construct a 2mm pitch GT2 belt as a sequence of 5 arcs, following the original design specification (here: https://www.thingiverse.com/thing:4767029 ), and it requires a bunch of ugly list comprehensions. I managed to add a function to “bend” the resulting 2d profile to generate a pulley, but I have duplicate vertices in my list that create thin faces that crash the CGAL renderer, and can’t quite work out a functional way of “removing doubles” a function that is an inbuilt in other mesh editors. (I used “offset(delta..” , but it’s ugly). It would be SO much easier if there was a sane way to define functions and objects. It might be “for coders”, but they must have some masochistic tendencies.
I posted a reply to this with some options you may find useful, but alas it ended up as a standalone comment below (grr, I so hate Hackaday’s comment system)
Another option for 2D parametric line drawings is https://cuttle.xyz/
This is a 2D sketcher that can import and export DXF.
It can uses 2d constraints.
https://autodrop.cloud/jsketcher/sketcher.html
I for one love how the term “web technologies” gets used in some parts, along with some requisite hand waving, without a hint of sarcasm or irony, as if scripting and markup languages are something new and amazeballs.
It is new and amazeballs if some VC throws a few million at it because of it. Some of these “web” specs are clearly written to awe “investors”. So the short sale likely happened at the very beginning of the journey.
What I miss most in openscad, is the reference to objects (and with that their faces, geometries. etc.)
A good example is pgf/tikz from the Latex world, where you can describe the position of objects relative to others.
A left of B
C above D
It would save a ton of math, errors and fiddling, if openscad would allow placing e.g. a sphere above a cube independent of the geometry of the cube, or sphere
so, slightly merging a sphere on top of a cube (which is located a bit down in z for whatever reason)
h = 100;
r = 10;
translate([0,0,-15])cube([10,100,h]);
translate([0,0,h+r-15-3]) sphere(r=r);
would become:
A = translate([0,0,-15]) cube([10,100,100]);
translate([0,0,A.above-3]) sphere(r=10);
Tried to visit https://openscad.cloud/openscad/ and got a warning that “This domain is currently on the MetaMask domain warning list. This means that based on information available to us, MetaMask believes this domain could currently compromise your security and, as an added safety feature, MetaMask has restricted access to the site. To override this, please read the rest of this warning for instructions on how to continue at your own risk.”
Please report that as a false positive. This is the second time some one has gotten this msg.
They might be flagging because of the use of WASM. I know that there are some crypto mining tools that use wasm to mine from your browser. You can look at the task manager to see that the thread is only active when the run button is pressed to process the model and display it. Once it is done running and returning the visualization there is no CPU load.
OpenSCAD is awesome! I hated all CAD systems before I was able to try OpenSCAD. As a programmer who just needs to 3D Print cases, standoffs and such I love this simple system. What would really be great would be a official OpenSCAD library. Ther are plenty but often you need a lot of glue to put them together.
Agreed. Let there be libc for OpenSCAD! libscad!
First, you are overstating the problem. Yes, there are some web apps which don’t work as browsers are modernized. But most still do.
Second, you are underreporting the options available to fix the problem. To run in a browser, the source code MUST be available. It might be obfuscated, but it’s there. Someone who knows Javascript and the web in general CAN fix the issue and make it work again.
Third, you are completely under-reporting the issues with OS changes. There are several Windows programs which I can’t run anymore unless I keep an old copy of XP or 7 around. And installing a virtual Win on my Ubuntu machine has proven difficult enough that I haven’t completed it… the licensing keeps stopping me. I don’t think OS issues are less than browser issues.
But most importantly, you are leaving out the fantastic advantages of portability.
The REAL issue with the web are things that require server side support. IOT device support with online databases are my pet peeve; how long before the device I paid for stops working because it can only connect to the corporate server?
Look, yes it can be a problem when browsers stop supporting something. I spent a bunch of time with my son writing a digital logic tutorial using a Java based simulator. Chrome doesn’t support Java anymore. But… there is now an add in (extension) that allows you to run the JVM in Javascript, and it works quite well! We can solve these incompatibility issues, we just need to roll up our sleeves and get to it.
The issue I have with this is it’s slow.
https://openjscad.com/
appears to me to be MUCH faster and it uses a well document, commonly used, real programming language. I completely fail to understand why using a non-standard language with serious limitations and a limited library of functions is preferable.
I’ve struggled with that myself. There’s the odd library for OpenSCAD designed for helping to work with 2D, mostly aimed at laser cutting (like https://github.com/bmsleight/lasercut). But really it’s all just hacking 2D into something that tries very hard to not be 2D – everything 2D is still represented as a 3D object (which, fair enough – it’s a 3D modeller & 2D was never it’s aim). I found it all too frustrating for 2D and moved on to other tools.
You might be interested in MakerJS (https://maker.js.org) – which was specifically designed to be code-based parametric 2D line drawings for laser cutter designs (& other 2D CNC). Frustratingly development has slowed significantly, but the base is there & usable.
But there’s also a bunch of tools made for generative art & data visualisation communities that can be repurposed for this, depending on your specific needs. I find the hard part is usually support for units, but you can usually get around that easily if it exports to SVG (naively or via a plug-in). But there’s also the odd one (or plugin) that can directly export to DXF. Some examples:
D3 is made for data visualisation, but it’s incredibly versatile. Massive community & number of plugins & other libraries/platforms built on to of it. It’s my current go-to for a lot of stuff (2D generative art & 2D CAD).
Observable (https://observablehq.com) is kinda a mash up of Junyter style notebooks & D3 data visualisation, but versatile enough for almost anything. It’s designed primarily around D3, but it’s designed so you can import any JS library (& external data). The notebook aspect can be really useful for having an entire project, with documentation, in one document. Export options are a bit thin, but it’s incredibly versatile & has an amazing community (& source for inspiration). At the very least, it’s a good place to experiment and play with/test ideas. It’s not aimed at CAD, but it is inherently & deeply parametric by design.
P5.js (https://p5js.org/) is an interpretation of Processing for the web implemented in JavaScript, and supports plugins that can make it more usable for CAD (p5.svg, p5.fab, and p5.start2d).
Two.js (https://two.js.org/) is a JavaScript library targeted at 2D drawing with SVG export. It’s been on my list for awhile, but I haven’t gotten any experience with it yet.
Buerli (https://buerli.io/) is something I stumbled on just the other day & don’t know much about. Seems to be still in early beta stage. But on first glance seems to hold promise as a full 2D & 3D CAD system using a JavaScript API.
Learning CAD is a MASSIVE INVESTMENT – it takes hundreds of hours to become proficient, so wasting your time with antique open-source garbage is completely stupid. It’s like learning latin to become a poet. You fill your brain with obsolete junk, and become proficient at something nobody uses with no future in it.
Don’t damage your CAD future – go find a real CAD package that is popular and supports modern machines and parametric techniques, and learn that.
And guess what – inside the “tools” menu is a working script language already (and more!), for all you die-hard coders out there – you can have your code and GUI it too.
well, not everyone has the time to invest hundreds of hours learning Fusion 360 or whatever just to create some simple geometry. I know F-360 is really cool and you can do lots of amazing stuff. But OpenSCAD is actually pretty great for people who aren’t professional 3D artists or draftpersons, but have a mind for code
Hmmm. If you are employed and using a professional CAD package paid for by your employer then you will still have to learn the chosen package. But if your a hobbyist or need to design a few parts OpenSCAD is a great free solution. Unless you can’t type, read, or write.
I find OpenSCAD much simpler than Inventor, Fusion 360, FreeCAD, and Solidworks. Time invested to master it is 1-10% of what’s required in Inventor. Time to type in a new part is 1-10% of the time to use the Mouse to Select A Tool, Point Click, Type in a Number, Repeat… Using “Variables” (Actually Constants) turns it into a Parametric CAD Package. The hull() method is amazing letting you round your corners. And all OpenSCAD commands fit on a one page cheat sheet.
Compare that to Inventor where you have 8 to 12 tabs of different toolsets. And then you have to dive down to find the operation you want, and maybe AutoDesk moves it or eliminates it when you receive your yearly update. Or how about opening the dialog to enter a parameter, then having to move from the mouse to the keyboard to enter it, then having to close that dialog and move back to the mouse to use it. Oh but then you have to open another dialog and move back to the keyboard to type in the name of the parameter.
Or maybe you started with Inventor and now are forced to use Fusion 360 and have to learn a whole new set of commands.
Or you could use an educational version of Inventor or Fusion 360, and spend Months learning the application and then either have to pay to continue or hope that you don’t loose access to your design when you no longer qualify. After all AutoDesk needs to get paid for their product.
OpenSCAD is very powerful. Its easy to learn. Its not going to go away. And if you absolutely must insist on making it more complicated you can download and modify the source. I wouldn’t change it one bit. It would be great if 20 years from now it still just works.
I love OpenSCAD and use it all the time. It’s pretty awesome, but also not too great.
I don’t know if it’s Turing complete, but I suspect that it is. It is a language of some sort, but more akin to html than python. Your scad code describes a tree of geometric primitives with operations, and modifications that manipulate those primitives. It does not “run” in the traditional sense. There is no instruction pointer, no flow control, no mutable variables. It does have functional features including list comprehensions (which are quite handy) and many functional idoms will work:
/// some scad code to generate the vertices of the cuboctahedron ///
function ps(s)=flatten(
[ for(a=[-s/sqrt2,s/sqrt2], b=[-s/sqrt2,s/sqrt2])
[ [a, b, 0],
[a, 0, b],
[0, a, b] ]]);
function flatten(l)=[ for(a=l) for(b=a) b ];
sqrt2=1.41421;
/// end code – as found in https://www.prusaprinters.org/prints/151238-cuboctahedron/files
I think there is some flatten function provided by the language, but the definition is quite trivial.
I know my style is terrible and my coding skillz are not 1337.
“for” inside a module is actually something completely different from “for” inside a function
This “for” statement is not a loop. It does not contain procedural code. It defines a tree structure, which resolves into a list. There is no order of execution. Variables can be defined at the end rather than the beginning because nothing is really before or after anything else except inside of a non-commutative operation such as difference()
If someone wants to hack on OpenSCAD, it could use a modern GPU powered rendering engine… something that’s not a single thread shared by all running instances of the software. (if a model is rendering in one instance, any other instances running on the same system must wait while one cpu core is pegged at 100% and the others sit idle)
Maybe I’ll eventually switch to OpenJSCAD or some other. Or maybe I’ll even have a go at writing my own. I liked Lex/Yacc (Flex/Bison) back in college and would enjoy working with that again. I don’t know anything about drawing a 3d object on the screen or exporting to stl/3mf/etc…
OpenSCAD seems to have a near monopoly on the community though. If you want to write something that others will adopt/extend it kind of seems like it has to be OpenSCAD.
Remember the excitement about printing machines from back in the RepRap days? That’s what I want to see more of, and be a part of. I’ve been working on designs for machines and functional (not knick knack) objects. I like them to be parametric, the more configurable the better. Wouldn’t it be great to have designs so adaptable that one can pull all the vitamins from their junk box and have things just fit? The more I work on this sort of thing though the more I run into OpenSCAD’s limitations.
And I do think it is ok that one language has such a monopoly on the community BTW. What good is sharing source code if everyone is using a different language? And despite the missing features I complain about OpenSCAD does have a LOT of potential for this sort of use.
Who else has a customizer window like OpenSCAD? I love that! A non-coder can easily take one of my openSCAD designs and tweak all the parameters from the customizer without knowing anything about writing code! There are even OpenSCAD customizers that can be embedded in a webpage. I love the idea that I can design a thing, throw it on the internet and somebody can come around who doesn’t code, click a couple drop downs and get a custom STL of my design that perfectly fits with the fasteners, switches, displays or other components that they have on hand.
So anyway, yah. Maybe if I can just convince enough people that the “don’t be a programming language” philosophy is an anchor holding OpenSCAD back….
And it’s not like adding a couple new features means all the people that don’t want them have to use them. Breaking people’s existing code and/or use cases is the last thing I would want to see.
Was meant for Egotron
https://www.blockscad3d.com/editor/#
Its great that OpenSCAD is ported to the Web.
I had found OpenJSCAD with its ability to run OpenSCAD code on the web, but it went away, and came back without the OpenSCAD option. Which means I would have to learn JavaScript to teach OpenJSCAD to students with ChromeBooks. I find the OpenSCAD commands to be simpler than their JavaScript equivalents. And I didn’t want to learn another CAD package after using OpenSCAD. When learning a new topic (CAD) simpler is better.
Our School District hands out Chromebooks to our students. They are locked down so students may not install applications. A web interface to OpenSCAD enables all students to design a part. While also learning a little bit about programming, typing, reading and writing. Its a perfect application.
Check out blockscad, it’s like scratch but openscad. Totally designed for kids to use for learning that stuff.
This is indeed very cool, especially with how ubiquitous Chromebooks have become in primary and secondary level education, at least here in the United States! I work as a computer technician for a public school district and when we got our first 3D printers, back around 2015 or so, I was looking for decent options for 3D modeling that didn’t entail getting locked into restrictive, expensive, complex, proprietary CAD tools. I stumbled upon FreeCAD and got a little frustrated with that. When I found OpenSCAD, having a CS degree, things just clicked! I’ve used it for all kinds of really cool and really useful projects both at work and on my own! Just today I was re-tooling a tiny computer mounting bracket design to fit a different TV mount of ours. Parameterized design of the original made adapting that easy!
I’ve held some sessions here and there teaching students as young as 5th graders about OpenSCAD, as well as co-workers. That was several years ago when computer labs of Windows PCs were more commonplace. These days, with the iron grip that Google now has on public education, for better and/or worse, at least in the United States, finally having the ability to nicely run OpenSCAD in a web browser truly is awesome! Sure, there were other ways in the past that were feature-limited, and sure, as it stands there are undoubtedly some aspects that need adding and refining, but I’m excited to see where it goes from here! I’m thinking I’ll have to whip-up some updated video tutorials to try and coax some students into giving it a try over Tinkercad! I’m not keen on proprietary tools being so much of the focus when learning CAD in secondary (Autodesk Inventor and Fusion 360, as well as Trimble SketchUp) and even primary schooling (Autodesk Tinkercad). I want to own the recipe for my models. I don’t want my models to be a recipe only crafted with a proprietary tool! Now, getting experience in GUI-based tools used in industry has its place for getting further schooling to eventually get a job using said tools, though I think OpenSCAD should certainly have a place in primary and secondary school as well!
As stated in past comments, it hones such a wide variety of skills that aren’t necessarily honed with interactive, GUI-driven modelers. There are the computer science aspects, which are overt. Though there’s certainly keyboarding skills. There’s skills of commenting on your model’s textural description and the fact you can be sloppy or neat, detailed or cryptic, when designing your models. You soon learn the importance of being neat, detailed, and methodical! Tons of mathematics and 3D spatial thinking and problem solving! When you really get into it, it’s tons of applied math fun! It’s an accidental edutainment! It gets to a point where it’s math and CS meets playing with LEGOs! I’d also personally completely concur with previous comments about OpenSCAD vs. OpenJSCAD. Perhaps it’s a result of cutting my teeth more with C programming, like the commenter also stated, but there’s so much you can do easily in OpenSCAD without the extra boilerplate verbosity of OpenJSCAD. I’m sure I’d feel different if I had a love for JS. Of course, you can certainly make some very messy projects in OpenSCAD if not disciplined!
You can get younger than 5th grade if you’re using blockscad, which is just a scratch wrapper around an openscad code generator which feeds into openjscad. Lets you see the code it generates, too, for easy transition to openscad proper. Runs on chromebooks too last I checked!
Do you have a repository for the 3D G-code previewing in OpenSCAD? Been wanting to look into that sort of thing for a while.
I’m working on a project to make the OpenSCAD customizer more approachable for non programmers. The website models.makewithtech.com is a front end to the current release of OpenSCAD that presents a customizer like UI for previewing and rendering models.
It includes a repository of OpenSCAD models and anyone can share a model via this site.
The backend runs the current OpenSCAD application in command line mode in AWS using a combination of Lambda Servers and Containers.
It supports uploading (sharing) of OpenSCAD models and also one time uploads if you prefer. I am very interested in feedback from the folks in the OpenSCAD community.
It also supports retrieving existing OpenSCAD models from Thingiverse and using this working customizer with them.
P.S. The next major release in about 4-6 weeks will include full support for including a ZIP file with modules, fonts and drawings (SVNs) for inclusion with your script. This will allow creators to share models with a snapshot of the external files they require.