Code Monkey home page Code Monkey logo

python-admesh's Introduction

ADMesh bindings for Python

https://img.shields.io/github/license/admesh/python-admesh.svg?style=flat

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

There are wheels available for Linux and macOS X. All you need to do is:

pip install admesh

If you have a platform not supported by the above, you'll need to install the C 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.