4 ms·
is there any programming style for it which doesn't look like some crazed 90s java, with all the method chains? something with contexts would be nice, maybe?
by sigstoat 5y ago
is there any programming style for it which doesn't look like some crazed 90s java, with all the method chains?
something with contexts would be nice, maybe?
with cq.Workplane("XY").box(h,w,t) as plate:
plate.faces(">Z").workplane().hole(diameter)
show_object(plate)
there's got to be some compromise between the explicitness of cadquery, and the implictness of openscad.
- bvrmn 5y ago> there's got to be some compromise between the explicitness of cadquery Most cadquery examples are hard to follow due to context implicitness. They are basically write only.
- deleted 5y ago[deleted]
- sfvisser 5y agoWhat’s crazy about it? And how would contexts by more ergonomic than method chaining? Hard to imagine honestly. You can always use intermediate variables if you want to.
- ssl232 5y agoI generally dislike fluent interfaces too, so much so that it stopped me from trying CadQuery initially. Only once I encountered something I couldn't do with OpenSCAD did I give it a go and now it's the only tool I use. It is one of the rare cases where fluent works very nicely. Because it's python, you can always use parentheses to split long lines neatly.
- Already__Taken 5y agoand IMO that should be the default example not using escapes \
- ssl232 5y agoIndeed. It's pretty widely accepted in the Python world that \ should never be used. Black for example zealously removes them. Perhaps if we ever get a Python 4, it can actually be removed (along with other minor annoyances like the camelCase in the logging library!).
- paulftw 5y agoThere are actually at least two styles that do exactly that. They are called OpenSCAD and JSCAD. The code above would be simple subtract(cube([h,w,t]), translate([h/2,w/2,t], cylinder({radius, height}))) I don't know why the article makes it sound like cadquery is superior in every way possible. Sure BREP is a lot more powerful than CSG, but with extra power comes extra learning curve. If all you ever design is 3d prints for reprap (and I'd guesstimate 95% of hackaday audience falls into that category) cadquery may be an overkill
- sigstoat 5y agoi'm perfectly aware of openscad, i literally referenced it in my question. you've completely wasted both our times.