Get dimensions of an STL file
Project description
stldim
Makes a library tailored to an existing STL file. Move it to the origin in OpenSCAD.
It is an enhanced version of https://github.com/lar3ry/OpenSCAD---Move-STL-to-origin which in turn is based on stldim.py, by Jamie Bainbridge. Their version can be found at:
https://www.reddit.com/r/3Dprinting/comments/7ehlfc/python_script_to_find_stl_dimensions/
The script will create an OpenSCAD library which will allow you to place an STL file to 6 different positions in relation to the origin:
CTR put's the center of the STL to the origin of the OpenSCAD coordinate system. CTRXY puts the center of the STL to the origin of the OpenSCAD coordinate system, but only in the XY plane. NE, NW, SW, SE put the STL to the origin of the OpenSCAD coordinate system, but only in the XY plane, and in the direction of the compass point.
In the generated library, a module <name>_obj2origin() is created which you can use to place the object.
Name is derived from the basename of the STL file, with all non-alphanumeric characters replaced by underscores (e.g. My Object.stl becomes My_Object_stl).
The script will also define variables for the x-, y-, and z-size and -position of the object which can be used for other calculations in your code.
Prerequisites
You will have to install stl, numpy, and numpy-stl Python packages in case you don't have those already.
pip3 install stl
pip3 install numpy
pip3 install numpy-stl
Usage
Place the stldim.py file where you keep your Python executable scripts. Its usage is like this:
stldim [stl file] # prints the result in stdout
stldim [stl file] > [scad file] # writes the result into a .scad file
On a command line, CD to the directory containing the STL you wish to move, and run the script, giving it the name of the STL file as an argument. If you wish, you can redirect the output to a library file as well (see the example below).
Acknowledgements
This project is based on https://github.com/lar3ry/OpenSCAD---Move-STL-to-origin and enhances it with additional features.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stldim-0.1.0.tar.gz.
File metadata
- Download URL: stldim-0.1.0.tar.gz
- Upload date:
- Size: 4.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
597f42ec81d1552c260889f80de25e4487169643c516fc29a0d21284f41f94fb
|
|
| MD5 |
90647f4d40c45818e2a21b309f9050ce
|
|
| BLAKE2b-256 |
a04e75638ab8e29ab6c5151a151c0ec03926810c058a49926103789d8ec25dce
|
File details
Details for the file stldim-0.1.0-py3-none-any.whl.
File metadata
- Download URL: stldim-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3bc056a1c8d9b9b29060977e7d72ec99e3b6c6417103d2dbf2fdebd30d25ae0b
|
|
| MD5 |
f2970636bcca60ece36e295bbd86b531
|
|
| BLAKE2b-256 |
8627a4c7f3463204e1ccda92659a2496f667ae55bbc8c087cda7d5f5ed3f4f9a
|