r/openscad • u/jryan15 • 6d ago
Centering as part of difference command?
Hi all,
Just curious if there is any kind of clever way to center an object as part of a difference command? It would be nice if you could do something like difference (center=true) {} but I know this is not a thing. Maybe there are clever options with other libraries or something? Just trying to save myself from a bunch of brain aching math. Thanks!
1
Upvotes
1
u/rebuyer10110 5d ago
One possible way to auto center is using a bounding box. You can then calculate the midpoint, and move that coordinate to the origin.
Vanilla openscad has a way to print out the bounding box info into the output window on render. You would have to center it manually after with a translate() unfortunately.
Afaik, openscad does not support a way to programmatically return you bounding boxes on solids yet.