Live data from Hacker News

CadQuery: A Python parametric CAD scripting framework based on OCCT

github.com

21–30 of 47 posts

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

#21
post #15

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?

Doesn't it being Python (any programming language - OpenSCAD/declaracad too) basically give you constraints for free? I haven't actually played around with it yet, but surely it's just a matter of combining (or computing from) your (python) variables appropriately? And even having the ability to `assert x > 10` or whatever to validate allowable parameter ranges.

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

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

#22
post #21
post #15

Earlier quoted context omitted.

Doesn't it being Python (any programming language - OpenSCAD/declaracad too) basically give you constraints for free? I haven't actually played around with it yet, but surely it's just a matter of combining (or computing from) your (python) variables appropriately? And even having the ability to `assert x > 10` or whatever to validate allowable parameter ranges.

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.extrude(z)

    radius = y/2 if y 
The circle cutout inherently has tangent constraints on the sides of the box, without needing library support or a solver.

I realise there are limits, I just think you could do a lot without hitting them, and when you do.. you're just programming, find a constraint solver to use.

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

#23
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 like with the constraint system and so on.

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

#25
Big fan of Cadquery! I used it to generate circuit board enclosures in an old project of mine[1]. Once you have it set up it is much nicer to use than Openscad and you have the ability to export STEP files, which is pretty huge. I haven't played with it in a while but the new improvements look great. The maintainers are also very welcoming/helpful to newcomers. Overall a great open source project.

[1] https://enclosuregenerator.com/

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

#26

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…

FreeCAD has an sketch [1] workbench with constrains. Once it's draw, you can extrude it, pad it, apply the geometric boolean operations, add/substract to create complex parts [2] from the result.

[1] https://wiki.freecadweb.org/Basic_Sketcher_Tutorial

[2] https://wiki.freecadweb.org/PartDesign_Workbench

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

#27
post #16
post #9

I don't really have experience with the architecture of CAD applications. What's the relationship between a CAD program and the OpenCascade kernel? Since both this and FreeCAD use OCCT are files compatible between them?

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?

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

#28
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,…

STEP doesn't have modeling history though.

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

#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.

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

#30

Earlier quoted context omitted.

How can you size shafts without engineers? Who does the calculation and review? Who is liable if it fails and someone gets hurt?

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.

Post reply on HN