Skip to main content

Get dimensions of an STL file

Project description

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 origin
  • CTRXY - Center the object on the origin, but only in the XY plane
  • NE - Put the object in the North-East corner of the XY plane
  • NW - Put the object in the North-West corner of the XY plane
  • SW - Put the object in the South-West corner of the XY plane
  • SE - 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stldim-0.1.1.tar.gz (4.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stldim-0.1.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file stldim-0.1.1.tar.gz.

File metadata

  • Download URL: stldim-0.1.1.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

Hashes for stldim-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3cbd0bc7de1e1316ecaf1fdde9ae607910b7de8b73567087a02f7f8920dcf266
MD5 ded8692bc8582a88984ade9ddd7e768b
BLAKE2b-256 26de3fc02df7f0dfa8b298492ed15be12c740b5c7a1e9533e25c27e8271b78ba

See more details on using hashes here.

File details

Details for the file stldim-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: stldim-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.6

File hashes

Hashes for stldim-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c1d4c6eecdba8d0cfc21046ff0ce0c7a4f32ff89fae3d1fe397d3a5231bf3d44
MD5 1aa112d926e08200c905d1f2c7ec30a8
BLAKE2b-256 21f1a5aa7eca1e6feb1eff6008cf5fa8328384f71adf7548811ddeeaef1e7cad

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page