Skip to main content

Python bindings for ADMesh, STL maipulation library

Project description

https://img.shields.io/pypi/v/admesh.svg https://img.shields.io/travis/admesh/python-admesh/master.svg https://img.shields.io/github/license/admesh/python-admesh.svg?style=flat https://img.shields.io/pypi/pyversions/admesh.svg https://img.shields.io/pypi/implementation/admesh.svg

This module provides bindings for the ADMesh library. It lets you manipulate 3D models in binary or ASCII STL format and partially repair them if necessary.

Installation

First, you’ll need to install the ADMesh library. This release is designed for ADMesh 0.98.x. Follow the instructions there. Then you can install this as usual with one of the following:

./setup.py install
python3 setup.py install # for Python 3
pip install admesh # install directly from PyPI

In case your ADMesh library is located in non-standard location, you’ll have to tell the compiler and linker where to look:

LDFLAGS='-L/path/to/library' CFLAGS='-I/path/to/header' ./setup.py install

Usage

Use the Stl class provided.

import admesh

# load an STL file
stl = admesh.Stl('file.stl')

# observe the available methods
help(stl)

# read the stats
stl.stats

# see how many facets are there
len(stl)

# walk the facets
for facet in stl:
    # get the normal
    facet['normal']
    # walk the vertices
    for vertex in facet['vertex']:
        # read the coordinates
        vertex['x']
        vertex['y']
        vertex['z']

# add another set of facets
# every facet is a tuple (vertices, normal) or a dict
stl.add_facets([
    (((0, 0, 0), (0, 1, 0), (0, 0, 1)), (1, 0, 0)),
    {'vertex': [{'x': 0, 'y': 0, 'z': 0},
                {'x': 1, 'y': 0, 'z': 0},
                {'x': 0, 'y': 0, 'z': 1}],
     'normal': {'x': 0, 'y': 1, 'z': 0}},
])

Note that all C ADMesh functions start with stl_ prefix and the Python methods of this module do not. Also note that not all C ADMesh functions are provided, because some would require more complicated approach and are not considered worthy. In case you are missing some functions, create new issue.

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

admesh-0.98.7.tar.gz (70.3 kB view details)

Uploaded Source

File details

Details for the file admesh-0.98.7.tar.gz.

File metadata

  • Download URL: admesh-0.98.7.tar.gz
  • Upload date:
  • Size: 70.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for admesh-0.98.7.tar.gz
Algorithm Hash digest
SHA256 cdc264e67656c84039f5691d467f26ac5b790b5d08d8c690ac248b38920ae4d2
MD5 2bbc206179b9ad2a72d8625ab2fe84d0
BLAKE2b-256 749daed79bb02eb0110a1dabaa7d3c04e889cfed60ed5f4049a75978c5b54d50

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