2D irregular bin packaging and nesting for python
Project description
Introduction
Nest2D is a 2D bin packaging tool for python.
Nest2D works with the C++ libnest2d backend for speed. For python C++ interoperability we use pybind11.
The library is written in a way that it should be usable out of the box with a very simple interface. The backend is reasonably fast and robust, being built on top of boost geometry and the polyclipping library.
Example
A simple example may be the best way to demonstrate the usage of the library.
from nest2d import Point, Box, Item, nest, SVGWriter
def add_item1(n, items):
for i in range(n):
item = Item([
Point(-5000000, 8954050),
Point(5000000, 8954050),
Point(5000000, -45949),
Point(4972609, -568550),
Point(3500000, -8954050),
Point(-3500000, -8954050),
Point(-4972609, -568550),
Point(-5000000, -45949),
Point(-5000000, 8954050)
])
items.append(item)
def add_item2(n, items):
for i in range(n):
item = Item([
Point(-11750000, 13057900),
Point(-9807860, 15000000),
Point(4392139, 24000000),
Point(11750000, 24000000),
Point(11750000, -24000000),
Point(4392139, -24000000),
Point(-9807860, -15000000),
Point(-11750000, -13057900),
Point(-11750000, 13057900)
])
items.append(item)
def main():
box = Box(150000000, 150000000)
input = []
add_item1(23, input)
add_item2(15, input)
pgrp = nest(input, box)
sw = SVGWriter()
sw.write_packgroup(pgrp)
sw.save()
It is worth to note that the type of the polygon carried by the Item objects is the type defined as a polygon by the geometry backend. In the example we use the clipper backend and clipper works with integer coordinates.
Example call
$ pip install nest2D
$ python examples/simple_sample.py
Example output
License
Unfortunately libnest2d is provided with a contractible GPL type license so we can not release this with better license terms. Details can be found in the LICENSE file. By using, distributing, or contributing to this project, you agree to the terms and conditions of this license.
References
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
File details
Details for the file nest2D-0.4.0.tar.gz
.
File metadata
- Download URL: nest2D-0.4.0.tar.gz
- Upload date:
- Size: 180.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7b4fd9b609f91aa9fb1b81b7ea635dd78a7044e6aa661a3aa147b46bdac0b27 |
|
MD5 | e59c6a8e8e3617499d8b4f7aec85f1eb |
|
BLAKE2b-256 | 9795e1ea465270c13561246aa93f19d61f7ae9071d2768ef16608e19ebb633a4 |