Live data from Hacker News

CadQuery: A Python parametric CAD scripting framework based on OCCT

github.com

41–47 of 47 posts

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

#42

This is really interesting and compelling to me. I tried FreeCAD recently and couldn't get into it, and went back to onshape. I notice that it doesn't appear to have constraints in it, which is usually a significant part of the CAD workflow. What does one do about that?

You could take a look at simpy.readthedocs.io, which provides some ways to handle constraints.

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

#43
post #22

Earlier quoted context omitted.

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.

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

    p, q, r = params("side1", "side2", "side3")

    pq = arccos((p^2+q^2-r^2)/(2*p*q))
    pr = # ... similar
    qr = # ... similar

    assert pq + pr + qr == 360, "Side lengths invalid"
    pside = line((0,0), (p,0))
    xy_qr = (r*cos(180-pr), r*sin(180-pr))
    qside = line((p,0), xy_qr)
    rside = line(xy_qr, (0,0))

    triangle = sketch(pside, qside, rside)
Or whatever this fictional API is to look like.

Obviously to do generic constraint solving, you need a generic constraint solver. My point is that if you have fixed known constraints, and a programming language, you can just compute what you want explicitly.

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

#44
post #4
post #3

I wish more people would try this over openscad. I like openscad but the UI and with cadquery you use python! and now I noticed "CadQuery supports Jupyter notebook out of the box"

I actually like the GUI way of designing in FreeCAD/Fusion 360 (which I wouldn't say about much) but for me it's about the file format on disk. I would love it if they had a sane human-readable format, git-friendly. I appreciate that wouldn't be trivial. So I'm really interested in learning something like OpenSCAD or CadQuery, even if only for files I can use and read anywhere.

I managed to integrate Jupyter notebook with FreeCAD to get some of both worlds. In the future I'll try to put CadQuery into that mix, also.

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

#45
post #6

Another open source alternative in the wake of the Fusion 360 debacle it seems. I will have a look. I'm no CAD expert and I have tried FreeCAD but it seems it's almost there but not yet. My use cases are very simple and this may be enough but nevertheless I think a GUI is the way to go for these kind of applications.

I avoided it from the start. I never checked if it was available for Linux, but in general I prefer software that is free from the start.

Sort of a "Show your work" kind of attitude. Theoretically I could assemble my software stack (almost) without any external licenses or closed source code.

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

#46
post #35
post #29

Earlier quoted context omitted.

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…

The big advantage of Python over Lua is that the ecosystem is bigger and more mature.

You can use SymPy for constraint modeling, for example.

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

#47

Earlier quoted context omitted.

It comes from the customers. They know what they want.

You guys aren't manufacturing from the cad files, are you? Like convert to gcode and send to a CNC? Or is it just for models only. I'm not in that industry, but it makes sense you'd have a use for it at least. The thing is that fusion360/solidworks/etc does parametric modelling so can probably be used just as easily, with the added benefit of being industry standards.

Where I see potential for using tools as cadquery is with product type configurators which are often part of ERP software aka CPQ (Configure-Price-Quote). Cadquery generated model would be part of the Configure. Of course this wouldn't work for complex product, but there are companies out there that may need a configurator for relatively simple product
Post reply on HN