13 ms·
CadQuery –- A Python parametric CAD scripting framework based on OCCT
- rajnathani 5y agoAlso: Discussion from 2020 September (134 points / 46 comments): https://news.ycombinator.com/item?id=24520014 https://news.ycombinator.com/item?id=24520014
- eggy 5y agoI started parametric geometry or CAD with AutoLISP, but you were tied to AutoCAD. Then I found Blender in the late 90's and early 2000's, and used Python to do some cool stuff. FreeCAD was my next attempt at using the engine without the GUI, but most of my daytime work in engineering is on Autodesk Fusion or Inventor, or in Rhino. Then I found Rosetta[1], a cool attempt at creating a geometry grammar and a backend for popular CAD programs like AutoCAD or Rhino. You code in Rosetta, a Racket DSL/library, and it renders in the CAD backend. I actually used it to generate a spherical truss dome that I could analyze structurally, change parameters, and reload in the analysis. I was almost at the point of doing my own version of generative design assist that Autodesk now has working. I started to think about writing a backend for FreeCAD, because I prefer Lisps over python for creative coding. I'll have to check CadQuery out now that it has moved from FreeCAD to OCCT. I still like writing AutoLISP for fun. Still not a fan of python for no good reason other than the biased reason that Lisp makes me happy, and python doesn't. CadQuery's Jupyter interface seems like a good sandbox to experiment with if the speed is good for iterative or historical design. [1] http://web.ist.utl.pt/antonio.menezes.leitao/Rosetta/index.html http://web.ist.utl.pt/antonio.menezes.leitao/Rosetta/index.h...
- samwillis 5y agoSlight aside, does anyone know of a more modern open source parametric CAD kernel than OpenCascade (which this is built on)? When I have looked into it before it seems to be criticised for being somewhat dated and not have the power and developer ease as Parasolid (which costs big bucks). Having both a software and mechanical engineering background (I spent a lot of time in SolidWorks) I regularly get the itch to try and combine the two and create a CAD tool.
- rjsw 5y agoThe only other open source full function CAD kernel that I know of is BRL-CAD, have only poked around a bit in it and OCCT.
- samwillis 5y agoYes, I have come across BRL-CAD but never tried it. I believe it’s even older and more complex than OpenCascade. How did you find the two of them?
- traverseda 5y agoIt Coin3D not full function?
- samwillis 5y agoCoin3D is a 3d graphics scene graph toolkit, it has no parametric solid models tools. I believe most tools built with OpenCascade use Coin3D for rendering.
- ramboldio 5y agosame itch here. Here are two quite remarkable statements from a MIT lecture on CAD (https://stellar.mit.edu/S/course/6/fa19/6.807/courseMaterial/topics/topic1/lectureNotes/05_parametrization_basics_mit/05_parametrization_basics_mit.pdf https://stellar.mit.edu/S/course/6/fa19/6.807/courseMaterial... ): "[there are] ASIC and Parasolid, others are not really as good" and "[CAD] Research disconnected from reality [compared to CG research]" One might expect a whole range of CAD kernels floating around, since these kernels are such a fundamental part of civilization in some way. Doesn't seem to be the case, tho..
- samwillis 5y agoThat confirms the impression I had, I guess they are just so complex that building a new open source one from scratch would be Herculean effort. Guess OCCT is the only option for now. The itch I would love to scratch is an online real-time collaborative parametric cad app using CRDTs. Current thinking is combining OpenCascade compiled to WASM [0] with Yjs[1], but frankly don’t have the time. A kind of Figma but for 3D cad. (There is obviously onShape but I’m thinking something a little simpler) 0: https://github.com/donalffons/opencascade.js/ https://github.com/donalffons/opencascade.js/ 1: https://github.com/yjs/yjs https://github.com/yjs/yjs
- deleted 5y ago[deleted]
- mikebannister 5y agoI made this keyboard case with CadQuery. In the long run I'm working towards generating cases (and PCBs) for keyboards with many parameters available for configuration (e.g. number of columns, number of rows, number and position of thumb keys, case style, rotary encoders, etc). https://imgur.com/a/VfOyAjP https://imgur.com/a/VfOyAjP https://github.com/possibilities/unkeyboard https://github.com/possibilities/unkeyboard Note I chose a somewhat non-idiomatic approach (in terms of cadquery) writing this and I'm new to python.
- _benj 5y agoI've been actually considering multiple CAD options to design a keyboard... pretty cool to see that you did so!
- rgoulter 5y agoErgogen is a project in a similar spirit; it takes a YAML as an input and uses this to generate files for plates, or (unrouted) Kicad PCBs. I was also interested in having parametric CAD related to custom keyboard PCBs. The approach I took was to copy the PCB module data to a format the CAD program could use. That way, the Kicad PCB files would still be the "source of truth" for the PCB design, but I could use OpenScad to come up with the plates for the case. https://github.com/rgoulter/keyboard-labs/ https://github.com/rgoulter/keyboard-labs/
- mikebannister 5y agoYeah Ergogen looks cool but I'm learning a lot writing my own code (about CAD, PCBs, and keyboards). I generate geometry based on parameters that are just plain old data structures and then I feed that into 1) Cadquery for the case and 2) A simple library (that will be replaced with Kicad scripting later) to output a PCB. So the whole thing is idempotent and deterministic depending on the inputs.
- mikebannister 5y agoBTW started out with OpenScad but, among other things, CadQuery allows me to do it all in one language and access to many useful libraries.
- Already__Taken 5y agoI tried this a couple of months ago, I found what it's trying to do very pleasant to use but the tooling around it is very annoying. The up-to-date version 2 isn't on pypi, conda is thoroughly unpleasant to have as an environment. There seems to be a drive to using it inside it's own editor https://github.com/CadQuery/CQ-editor https://github.com/CadQuery/CQ-editor while nice seems like wasted engineering effort in developing an editor when the language needs so much work. I didn't have much success structuring cad into modules as they wouldn't import well. The point IMO of parametric cad in an existing language is to use the ecosystem. Lots of choices in this project make that really hard.
- bb88 5y agoYeah, I think their approach to blaming PyPi for not being able to distribute their 1GB standard install is really putting the blame on the wrong people. https://github.com/CadQuery/cadquery/issues/153#issuecomment-867371860 https://github.com/CadQuery/cadquery/issues/153#issuecomment... As an example of an approach that doesn't break Pypi, nltk distributes through Pypi but has an download() method for installation. https://pypi.org/project/nltk/ https://pypi.org/project/nltk/ https://www.nltk.org/data.html https://www.nltk.org/data.html The fact they're hostile towards pip (and ergo pipenv and poetry) just make it less than appealing software to want to use.
- dr_zoidberg 5y ago1GB is huge for PyPI. In this kind of situations, is there a good way to provide a PyPI install while providing a secondary channel to download the massive assests? Say that I was distributing a project that relies on a few large binaries, and still want it to be pip-installable, what would be the best way to do that?
- ur-whale 5y ago> conda is thoroughly unpleasant to have as an environment. Understatement, if there ever was one. Installing conda will maim your system irrevocably.
- jkic47 5y ago
- unfocussed_mike 5y agoThis is absolutely an impressive toolset, because it provides a bridge between the CSG => STL world (OpenSCAD, boolean operations, cutting shapes out of other shapes) and the STEP world of GUI CAD (faces, fillets, chamfers). I struggle with GUI CAD and I'm still learning all of this stuff at the most noddy level, but I am very conscious that I will want to send stuff out to be manufactured one day, and that means I have to be able to get beyond STL to STEP. So I am going to be spending more time with CADQuery and trying to use what it helps me visualise in FreeCAD as well. There is now a FreeCad workbench for CadQuery 2.0 which I have not yet tried: https://github.com/jpmlt/freecad-cadquery2-workbench https://github.com/jpmlt/freecad-cadquery2-workbench
- jker 5y agoOne thing that kept me using OpenSCAD was the section of additional modules for it, including a decent involute gear creator. For those of you diving into CadQuery, here’s the equivalent: https://github.com/meadiode/cq_gears https://github.com/meadiode/cq_gears
- l00sed 5y agoFor anyone interested in this, I would also recommend checking out the [antimony project](https://github.com/mkeeter/antimony https://github.com/mkeeter/antimony). It's a parametric modeling program, but you can also pretty easily produce new scripts for its visual nodes.
- traverseda 5y agoThe developer has since moved on to libfive and libfiv-studio.
- ssl232 5y agoFor the curious: https://libfive.com/ https://libfive.com/ and https://github.com/libfive/libfive https://github.com/libfive/libfive
- gxt 5y agoWhen I read parametric CAD I was hoping to see a tool that can automatically assemble full floor plans from just XYZ dimensions. Wiring, plumbing, structure, lighting, insulation, etc. Everything maybe except paint color. It's just another constraint solver, not sure why that doesn't exist yet and why we need to cough up billions in engineering and architecture costs every year. With a tool that can provide normalized, structured data corresponding to buildings, then for sure we could save on manufacturing too, every wall panel +- the same you could mass produce them. With a clever concept with datacenter-like floating floor you could even change and adapt the rooms (including plumbing) to suit needs without having to rebuild.
- HelloNurse 5y agoThe "design space" of architectural CAD models is mostly illegal (e.g. does your AI know how many parking spaces you must provide?) and/or lethally dangerous (e.g. is that beam strong enough?) so in the real world a constraint solver that saves time by automatically drafting, according to detailed specifications, detailed plans that certified architects and engineers can then analyze and sign off is the most useful possible tool.
- ur-whale 5y agoCut and paste of a recent comment I made in a similar thread: I've started to switch to Cadquery from OpenSCAD because OpenSCAD lacks proper fillets and chamfers. I usually prefer the CSG (arithmetic tree of union/difference/intersection + transforms + base shape leaves) to model 3D objects, as opposed to Cadquery's "draw on 2D surfaces and extrude" approach, but OpenSCAD's lack of fillets / chamfers combined with the "everything is a polygonal mesh" approach of the rendering engine is just too limiting. Cadquery has a lot of potential (the underlying engine uses a traditional hierarchical NURBS BREP, IIUC), but it also has a lot of shortcomings: Here are some I've bumped into: . very strange "stack-based" model. For complex objects, it's hard to wrap your head around it, and the workflow it forces on you as a user does not always fit your mental model of the object. . the underlying hierarchical nature of the object (the BREP) is forcibly hidden from the user, which leads to kafka-esque situations when one wants to e.g. select parts of an object. . selecting parts (faces and edges) in a object is a nightmare. cadquery has "selectors", which are a) its own weird little DSL b) very difficult to use on complex shapes c) does not support name-based retrieval: can't label things and get to them later by name. See this github issue for example: https://github.com/dcowden/cadquery/issues/29 https://github.com/dcowden/cadquery/issues/29 - the UI (cq-editor) is unusable for real-world work: no perspective rendering, no graduations in ortho views, no way to measure things on the object, no way to examine the BREP, etc ... Generally speaking, the UI is only a visualizer, and does not let you query / inspect the model in any detailed way. - fine-grain control over tessellation (conversion to mesh) is lacking. - good for modeling mechanical parts / lousy for modeling anything organic-looking - importing external models that don't fit the cadquery BREP-based represention is basically impossible. TL;DR: a nice tool to add to your belt, but not a very mature environment yet, and certainly can't replace OpenSCAD yet.
- defterGoose 5y agoAFAIK there isn't really another reasonable way of rendering other than having render meshes attached to everything (due to GPU architecture), but they shouldn't be getting used for any calculations so it also shouldn't matter very much.
- 5y ago