Live data from Hacker News

CadQuery: A Python parametric CAD scripting framework based on OCCT

github.com

31–40 of 47 posts

Re: CadQuery: A Python parametric CAD scripting framework based on OCCT

#31

Off-topic: I’ve seen a few posts about CAD programs recently, and it reminded me of a product that I want but haven’t found yet. I often need to draw 2D vector graphics for digital or print. Since I suck a bezier curves (and they feel imprecise anyway) and manually arranging and combining geometric shapes can be tedious I want an interface for drawing that mimics the sketch function of SolidWorks or Fusion360 and the…

I completely agree with this! I used Solidworks heavily for years and am so accustomed to drawing some lines, adding some constraints and dimensions with custom hot keys and boom I have my drawing nice neat and tidy exactly as I need it in no time.

These days I don’t do any 3D modeling but I’ll need to jump into Inkscape every now and then to do some graphic design or 2D UI mockup type stuff and I wish I could easily replicate the Solidworks drawing workflow.

I’ve found that I can get pretty close to the workflow I’m looking for in FreeCAD, but then I don’t have any of the artistic stuff I need. And obviously Inkscape has all the artistic stuff, but building a drawing with constraints and dimensions isn’t possible...or certainly not easy at least.

Re: CadQuery: A Python parametric CAD scripting framework based on OCCT

#32

Off-topic: I’ve seen a few posts about CAD programs recently, and it reminded me of a product that I want but haven’t found yet. I often need to draw 2D vector graphics for digital or print. Since I suck a bezier curves (and they feel imprecise anyway) and manually arranging and combining geometric shapes can be tedious I want an interface for drawing that mimics the sketch function of SolidWorks or Fusion360 and the…

I have also long desired something like this. I'd love a parametric vector (+ image) editor; it's an unfilled niche. (If any startup people are looking for ideas, here's your million dollar opportunity.)

There are the CAD programs, like SolveSpace/AutoCad/QCAD, but they aren't really designed for illustration: you would have to constantly export the blueprint to style it. I think the closest you can get now is UI design software with constraint features, but that software isn't really made for free-form work like Illustrator/Inkscape.

This discussion may be of interest to you, though it is not UI-based and none of the software has been open-sourced (yet): https://news.ycombinator.com/item?id=21774018

EDIT: Looks like Inkscape can do a few vaguely CAD-like things with "live path effects", but it's by no means a proper constraint solver. See the feature request here for a full constraint solver, which includes a summary of past progress and proposals: https://gitlab.com/inkscape/inbox/-/issues/1465

Re: CadQuery: A Python parametric CAD scripting framework based on OCCT

#33
I like the use of Roots blower rotors in the example screenshot --- as something that can be mathematically described relatively simply, but far more tedious to draw manually.

I was a little perplexed at the OCCT acronym at first; it refers to the stress testing tool overwhelmingly more than this.

Re: CadQuery: A Python parametric CAD scripting framework based on OCCT

#34
post #22
post #21

Earlier quoted context omitted.

Most of the graphical 3D CAD programs include a constraints solver that work over the domain of real numbers. A quick search doesn't turn up such a python library. https://wiki.freecadweb.org/Sketcher_Workbench https://forum.freecadweb.org/viewtopic.php?t=17868 https://en.wikipedia.org/wiki/CLP%28R%29

Ah sure, I was thinking quite loosely about 'constraints'. I think you can get pretty far without a solver, with a dependency order in a procedural language like python. Of course it's not as expressive, but I think it goes a long way, and just isn't possible or at least wouldn't be natural in GUI CAD. e.g. Scripted CAD pseudocode: x = param('length') y = param('width') z = 2*x + y base = rect(x, y) box = base.extrud…

Make a triangle with side lengths 7,8, and 9.

Also, one doesnt usually just find a constraint solver to use. You'll want a geometric constraint solver which will be built on top of a non-linear algebraic constraint solver. It really needs to be integrated into the CAD system.

Re: CadQuery: A Python parametric CAD scripting framework based on OCCT

#35
post #29
post #14

This almost made me stop working on my own openscad inspired system in lua. It has almost everything that I think is missing from openscad: * A full programming language * Fillet and chamfer support * A better viewer The thing that I'm planning to add to my lua cad is materials and PBR in the viewer. Also, I'm still thinking if native bom support is a good idea. But this looks slick, will definitely give it a try. Py…

Damn I didn’t realize OpenSCAD didn’t have filet/chamfer! Lua certainly has its advantages over python. The dubious choices are usually the most fun even if you end up in the deep end though.

Yep. Lua has a bunch of advantages even over python.

* It can be embedded in the viewer, so the user doesn't have to install a separate distribution of libraries. Only the viewer.

* It should be faster than python, even without luajit. Currently everything is done in lua, but I'm planning to write the main loop (converting the object graph into meshes and the rendering) into Rust. And have lua dsl fill in some arrays via C FFI.

* Lua has a special syntax for function calls that pass an object. Ex: do_something(obj) can be written as do_something { field = value }. This and some partial application can be used to make some very nice DSLs. Ex:

difference ( sphere { r = 3 }, cube { w = 2, h = 2, d = 2 } )

* Lua is a very simple language, which can be easily picked up. That being said, Python as used in CadQuery is also simple.

And yes, fillet and chamfer seem to be missing openscad. There is a way to do a 2d shape then add rounded corners then extrude it. But that seems to be new, and it's a bit tricky. I'm thinking about adding a fillet modifier that finds all the sharp edges in an object and rounds them. It might be more difficult than it sounds, but, will see. Fillets and chamfers are also important for visualisations, since in nature there are no perfect sharp corners afaik.

Re: CadQuery: A Python parametric CAD scripting framework based on OCCT

#36
post #32

Off-topic: I’ve seen a few posts about CAD programs recently, and it reminded me of a product that I want but haven’t found yet. I often need to draw 2D vector graphics for digital or print. Since I suck a bezier curves (and they feel imprecise anyway) and manually arranging and combining geometric shapes can be tedious I want an interface for drawing that mimics the sketch function of SolidWorks or Fusion360 and the…

I have also long desired something like this. I'd love a parametric vector (+ image) editor; it's an unfilled niche. (If any startup people are looking for ideas, here's your million dollar opportunity.) There are the CAD programs, like SolveSpace/AutoCad/QCAD, but they aren't really designed for illustration: you would have to constantly export the blueprint to style it. I think the closest you can get now is UI des…

Just curious: in what sense is that startup niche not yet filled by any of the usual 3d parametric CAD programs like Rhino etc.?

Re: CadQuery: A Python parametric CAD scripting framework based on OCCT

#38
post #32

Earlier quoted context omitted.

I have also long desired something like this. I'd love a parametric vector (+ image) editor; it's an unfilled niche. (If any startup people are looking for ideas, here's your million dollar opportunity.) There are the CAD programs, like SolveSpace/AutoCad/QCAD, but they aren't really designed for illustration: you would have to constantly export the blueprint to style it. I think the closest you can get now is UI des…

Just curious: in what sense is that startup niche not yet filled by any of the usual 3d parametric CAD programs like Rhino etc.?

The full blown 3D CAD programs _do_ have easily definable dimensions and a constraint solver for drawing sketches. The problem is that in these softwares, it’s typically assumed those sketches are going to be used to make a 3D part. So you’ll extrude the sketch along a line or sweep the sketch around an axis or something to create a 3D part. Consequently, what you can do artistically with the sketch ends there.*

I’m not looking for that 3D aspect of the software. Once I have the sketch dimensioned and constrained, I want to start doing artistic stuff with it like changing the line style or color, adding a gradient fill, adding text inside it—-stuff you’d use Inkscape and the like to do. But Inkscape doesn’t have the constraint solver or easy to use dimensioning tool.

*To be fair, you could probably export the line after fully defining it in CAD and import it into Inkscape, but that’s not much fun.

Re: CadQuery: A Python parametric CAD scripting framework based on OCCT

#39
post #17
post #16

Earlier quoted context omitted.

Open CASCADE is the geometry kernel that does all the heavy lifting (all the geometry related operations and mathematics etc). FreeCAD is a primarily a user interface plus Python script bindings around this kernel. CadQuery implements a Python-based scripting DSL around Open CASCADE to let you build models using code. File formats between these tools do not necessarily have to be compatible. Open CASCADE ships with e…

STL (and .OBJ) are common exchange formats for mesh output. For solids, which FreeCAD and OpenCASCADE mostly deals in, the typical exchange formats would be STEP (and IGES). Solids can have perfect circles, surfaces etc - where as meshes are just a bunch of 3d vertices with straight line between them. But still there is much information not present in a solid exchange format, like how the model was made: Constraints,…

>> STL (and .OBJ) are common exchange formats for mesh output. For solids, which FreeCAD and OpenCASCADE mostly deals in, the typical exchange formats would be STEP (and IGES).

Ah yes I meant STEP instead of STL of course, always mix those up. OCCT does not even have support for STL or OBJ import/export.

Re: CadQuery: A Python parametric CAD scripting framework based on OCCT

#40
post #16

Earlier quoted context omitted.

Open CASCADE is the geometry kernel that does all the heavy lifting (all the geometry related operations and mathematics etc). FreeCAD is a primarily a user interface plus Python script bindings around this kernel. CadQuery implements a Python-based scripting DSL around Open CASCADE to let you build models using code. File formats between these tools do not necessarily have to be compatible. Open CASCADE ships with e…

Thanks for the response! Is stuff like modeling history implemented in the kernel or in the FreeCAD code?

I’m not super familiar with the FreeCAD file format internals, but I assume it implements history using Open CASCADE API’s, in an application specific format. We have some internally developed CAD tooling based on Open CASCADE that uses the OCAF framework to store history inside a custom container format. Any code that links OCCT can in theory get the contents of the container using API calls, but to interpret it, you would have to write a lot of application specific logic on top of that (we wrote our own wrapper API’s around that to expose the file format to e.g. scripts etc)
Post reply on HN