stldim
A tool for mesuring the dimensions of an STL file.
Description
This is a python library which measures the dimmensions and coordinates of an STL file. It can be used as a library where you can use the measurements in your code, or it can be used as a command line tool which prints out the measurements as OpenSCAD code, so you can use it as a library in your OpenSCAD designs.
Acknowledgements
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/
CLI
If called from the command line, a library is printed to the terminal which can be used in OpenSCAD.
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.
Usage
stldim 3DBenchy.stl --name=object >benchy.scad
This will create an OpenSCAD library file benchy.scad which you can include in your OpenSCAD code:
include<benchy.scad>; // Include the generated library
bin_obj2origin(NE); // put the object in the North-East corner of the XY plane
Other options for obj2origin() are:
CTR- Center the object on the originCTRXY- Center the object on the origin, but only in the XY planeNE- Put the object in the North-East corner of the XY planeNW- Put the object in the North-West corner of the XY planeSW- Put the object in the South-West corner of the XY planeSE- Put the object in the South-East corner of the XY plane
Library
You can also import stldim in your python project and use the provided methods to get the dimensions of an STL file.
Be aware though, that this library is in a very early stage of development and the API might change significantly in the future.
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
Installation
pip3 install stldim
Metadata
Release files for stldim 0.4.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| stldim-0.4.2.tar.gz | 4.5 MB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| stldim-0.4.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.5 MB
Release files / stldim-0.4.2.tar.gz
| Download URL | stldim-0.4.2.tar.gz |
|---|---|
| Size | 4.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4c46f2021f94f3238fa71a932c133a72818442c2db6b17ec40ab964f29b4b9d5
|
|
BLAKE2b-256 checksum How to use checksums |
c5f50f17f57770c9d54e62ced877e5b1397e465a6a8dcca74a3f2867d02b2700
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.3
|
Release files / stldim-0.4.2-py3-none-any.whl
| Download URL | stldim-0.4.2-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e132f1a8d4f3f45b6d5902101ca374c9214c2d3a49a7ee987dfb2ed01524adf5
|
|
BLAKE2b-256 checksum How to use checksums |
db8abfe95d7fe82718f460c0796188075a10be34611da154c512abd7732814ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.3
|
Security for stldim 0.4.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.