This idea was inspired as a result of reading the replies in thread "Edge selector advanced example" which was started by me recently.
I have read [somewhere] that for optimum performance a simply-extruded object which lacks further complexity is best built in 2D and then extruded to 3D as the final step.
However I find myself sticking to the approach of creating 3D solids sooner rather than later, and then using the Workplane.cut(), intersect(), and union() methods. This just feels more intuitive, more natural to me.
I had a look at the
Sketch tutorial page:
https://cadquery.readthedocs.io/en/latest/sketch.html . There, upon first glances I didn't find explicit use of
cut(),
intersect(), and
union(), presumably because those concepts only apply to 3D objects, namely things associated with a
Workplane.
When I construct certain objects (good examples for that are straight-toothed involute spur gears or timing belt pulleys), I'd like to construct the 2D silhouette first by doing cut(), intersect() and union() in the 2D space, but because I have not learned how to do that intuitively using Sketch or other equivalent 2D concepts, I find myself extruding everything to 3D, with slight overlaps or overhangs to make cleaner operations, and then doing the boolean operations (cut/intersect/union) in the 3D space.
For example, to create my timing belt pulley, I first use Workplane.polygon() with circumscribed=True flag (is that flag even available for Sketch.regularPolygon()?). I then create a cookie-cutter cavity for each belt tooth cutout, which essentially consists of a 2D shape defined as a Workplane (again) using the constructs moveTo(), threePointArc(), lineTo(), and close().
What would be neat is if I could iteratively rotate this "2D cookie cutter cavity" when it's offset from the origin, thereby cutting out sections of the 2D polygon defined initially, all in 2D. Something like this.
However without biting my nails too much, without pulling my hair out too much, I've stuck to the method which I KNOW WORKS which is to extrude these objects to 3D and perform the boolean operations (cut/intersect/union) there. I do this because the several times I tried to do the boolean operations in 2D, it failed for me (and I didn't persist too long in my attempts). I'm sure that there is some "magic sauce" to this that I'm currently missing.
What are your thoughts on this? Am I missing something obvious when working with 2D objects? Or is my 3D approach "acceptable"? The 3D approach certainly makes things much more intuitive FOR ME.
I am about to pull the changes made for edge selection to give it a go.
By the way I'm not sure that you realize how powerful CadQuery is for large projects - for one, you can track changes as "diffs" between text files in Subversion or Git, because all your objects are defined as code [Python]. You can define constant files of far-reaching distances and offsets, diameters and tolerances. The actual code that generates your parts would then usually utilize formulas, directly in the code, by incorporating the various constants defined externally. I'm really surprised that more "engineering schools" don't teach this method of doing things. In a sense, I see CadQuery and such tools as a cross between engineering, mathematics, and computer programming/science, because all three skills are needed to be successful. I think in the future engineering schools will require their students to learn computer programming; I know for certain (esp. here in Germany) that this currently is not the case.
I have also found that OpenCascade is a very powerful engine, but I find myself needing to "dance around" some broken aspects of it. It's as if the engine was written by some very intelligent people who were a little bit impatient. Maybe Russians?