r/OpenPythonSCAD • u/rebuyer10110 • Jan 23 '25
Are there better ways of centering a shape in PythonSCAD?
I asked about built-in ways to center a shape in OpenSCAD: https://www.reddit.com/r/openscad/comments/1i7vg45/any_protip_on_centering_an_imported_stl_in/m8oxcak/
The TLDR: I can toggle on OpenSCAD logging for bounding box coordinates. Use that as a translation vector to move shapes' center to origin.
It's still repetitive if I want centers of faces of STLs I import. But at least with PythonSCAD, I can save them as handles and use align() :)
Out of curiosity: Are there better ways to do this in PythonSCAD that isn't as repetitive?
1
u/WillAdams Jan 23 '25
Why are you working from an STL?
What sort of shapes are you working with?
Image of them or sample file?
1
u/gadget3D Jan 23 '25
in pythonscad there is a mesh() function which can be used to extract the vertices, calculate the bounding box
and finally center the object.
would it make sense to add a center option to the import-stl function ?