ultimaker / pynest2d Goto Github PK
View Code? Open in Web Editor NEWPython bindings for libnest2d
License: GNU Lesser General Public License v3.0
Python bindings for libnest2d
License: GNU Lesser General Public License v3.0
Hi,
First, thanks for this binding.
I have a very strange problem : When I do the nesting and apply .transformedShape()
to my items, they get mirrored...
here an mwe :
import pynest2d as nest
w_p, h_p = 2480, 3508
w, h = 290, 314
bin = nest.Box(w_p, h_p)
items = [
nest.Item([
nest.Point(0, 0),
nest.Point(w, 0),
nest.Point(w, h),
nest.Point(0, h),
])
]
bin_count = nest.nest(items, bin)
it = items[0]
it_t = it.transformedShape()
pts = [ (it.vertex(i).x(), it.vertex(i).y()) for i in range(4) ]
pts_t = [ (it_t.vertex(i).x(), it_t.vertex(i).y()) for i in range(4) ]
print(pts)
print(pts_t)
I get :
Python 3.10.1 (main, Dec 18 2021, 23:53:45) [GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import pynest2d as nest
>>>
>>> w_p, h_p = 2480, 3508
>>> w, h = 290, 314
>>> bin = nest.Box(w_p, h_p)
>>> items = [
... nest.Item([
... nest.Point(0, 0),
... nest.Point(w, 0),
... nest.Point(w, h),
... nest.Point(0, h),
... ])
... ]
>>> bin_count = nest.nest(items, bin)
>>> it = items[0]
>>> it_t = it.transformedShape()
>>> pts = [ (it.vertex(i).x(), it.vertex(i).y()) for i in range(4) ]
>>> pts_t = [ (it_t.vertex(i).x(), it_t.vertex(i).y()) for i in range(4) ]
>>> print(pts)
[(0, 0), (290, 0), (290, 314), (0, 314)]
>>> print(pts_t)
[(145, -157), (-145, -157), (-145, 157), (145, 157)]
>>>
While the initial item "turns" clockwise (with xโ and yโ), the transformed one turns conter-clockwise.
It's not blocking to me if this is an expected behaviour, but it's weird, and if so, I think it should be mentioned in the readme.
My ask also is : is it consistent ? should I expect always all shape to be mirrored or is there situations where they are not ?
There is an error with this repository's WhiteSource configuration file that needs to be fixed. As a precaution, scans will stop until it is resolved.
Errors:
Hi folks!
I'm updating my Cura building on OpenBSD 6.8 and with this new dependency (pynest2d) I'm getting compile errors:
[5/10] /usr/ports/pobj/pynest2d-4.8.0-python3/bin/c++ -Dpython_module_pynest2d_EXPORTS -I/usr/ports/pobj/pynest2d-4.8.0-python3/pynest2d-4.8.0/src -I/usr/local/include/python3.8 -I/usr/local/include/polyclipping -I/usr/local/include -O2 -pipe -DLIBNEST2D_GEOMETRIES_clipper -DLIBNEST2D_OPTIMIZERS_nlopt -DLIBNEST2D_THREADING_std -fPIC -DNDEBUG -fPIC -std=gnu++11 -MD -MT CMakeFiles/python_module_pynest2d.dir/src/sippynest2dpart3.cpp.o -MF CMakeFiles/python_module_pynest2d.dir/src/sippynest2dpart3.cpp.o.d -o CMakeFiles/python_module_pynest2d.dir/src/sippynest2dpart3.cpp.o -c src/sippynest2dpart3.cpp
FAILED: CMakeFiles/python_module_pynest2d.dir/src/sippynest2dpart3.cpp.o
/usr/ports/pobj/pynest2d-4.8.0-python3/bin/c++ -Dpython_module_pynest2d_EXPORTS -I/usr/ports/pobj/pynest2d-4.8.0-python3/pynest2d-4.8.0/src -I/usr/local/include/python3.8 -I/usr/local/include/polyclipping -I/usr/local/include -O2 -pipe -DLIBNEST2D_GEOMETRIES_clipper -DLIBNEST2D_OPTIMIZERS_nlopt -DLIBNEST2D_THREADING_std -fPIC -DNDEBUG -fPIC -std=gnu++11 -MD -MT CMakeFiles/python_module_pynest2d.dir/src/sippynest2dpart3.cpp.o -MF CMakeFiles/python_module_pynest2d.dir/src/sippynest2dpart3.cpp.o.d -o CMakeFiles/python_module_pynest2d.dir/src/sippynest2dpart3.cpp.o -c src/sippynest2dpart3.cpp
/usr/ports/pobj/pynest2d-4.8.0-python3/pynest2d-4.8.0/src/ItemGroup.sip:49:25: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
while(list_item = PyIter_Next(iterator))
~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/usr/ports/pobj/pynest2d-4.8.0-python3/pynest2d-4.8.0/src/ItemGroup.sip:49:25: note: place parentheses around the assignment to silence this warning
while(list_item = PyIter_Next(iterator))
^
( )
/usr/ports/pobj/pynest2d-4.8.0-python3/pynest2d-4.8.0/src/ItemGroup.sip:49:25: note: use '==' to turn this assignment into an equality comparison
while(list_item = PyIter_Next(iterator))
^
==
/usr/ports/pobj/pynest2d-4.8.0-python3/build-amd64-python3/src/sippynest2dpart3.cpp:283:30: error: no member named 'isDisallowedArea' in 'libnest2d::_ItemClipperLib::Polygon'
sipRes = sipCpp->isDisallowedArea();
~~~~~~ ^
/usr/ports/pobj/pynest2d-4.8.0-python3/build-amd64-python3/src/sippynest2dpart3.cpp:356:21: error: no member named 'markAsDisallowedAreaInBin' in 'libnest2d::_ItemClipperLib::Polygon'
sipCpp->markAsDisallowedAreaInBin(a0);
~~~~~~ ^
1 warning and 2 errors generated.
ninja: build stopped: subcommand failed.
*** Error 1 in . (/usr/ports/devel/cmake/cmake.port.mk:36 'do-build': @cd /usr/ports/pobj/pynest2d-4.8.0-python3/build-amd64-python3 && exec...)
*** Error 2 in . (/usr/ports/infrastructure/mk/bsd.port.mk:2921 '/usr/ports/pobj/pynest2d-4.8.0-python3/build-amd64-python3/.build_done': @c...)
*** Error 2 in /usr/ports/mystuff/cad/ultimaker/pynest2d (/usr/ports/infrastructure/mk/bsd.port.mk:2584 'build': @lock=pynest2d-4.8.0; expo...)
I'm using SIP 4 version.
Do you have some tips to solve it?
Thanks in advance.
Evandro Rathke
Hi everyone
If I want to use BottomLeftPlacer I need to chance pynest2d.sip and rebuild the package or there's another way?
Can someone provide a brief code to explain how to use other placers?
I am trying to package pynest2d for alpine linux. I get the following error:
I am trying to compile this package for alpine linux.
I get a similar error on 4.11.0
, 4.12.1
/home/anjan/code/aports/testing/py3-pynest2d/src/pynest2d-4.13-beta/build/src/sippynest2dpart3.cpp: In function 'PyObject* meth_Item_isDisallowedArea(PyObject*, PyObject*)':
/home/anjan/code/aports/testing/py3-pynest2d/src/pynest2d-4.13-beta/build/src/sippynest2dpart3.cpp:281:30: error: 'using Item = class libnest2d::_Item<ClipperLib::Polygon>' has no member named 'isDisallowedAre
'
281 | sipRes = sipCpp->isDisallowedArea();
| ^~~~~~~~~~~~~~~~
/home/anjan/code/aports/testing/py3-pynest2d/src/pynest2d-4.13-beta/build/src/sippynest2dpart3.cpp: In function 'PyObject* meth_Item_markAsDisallowedAreaInBin(PyObject*, PyObject*)':
/home/anjan/code/aports/testing/py3-pynest2d/src/pynest2d-4.13-beta/build/src/sippynest2dpart3.cpp:352:21 1 ributor: Anjandev Momi <[email protected]>
: error: 'using Item = class libnest2d::_Item<ClipperLib::Polygon>' has no member named 'markAsDisallowedAreaInBin'
352 | sipCpp->markAsDisallowedAreaInBin(a0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/python_module_pynest2d.dir/build.make:155: CMakeFiles/python_module_pynest2d.dir/src/sippynest2dpart3.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/python_module_pynest2d.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
hello hello i am trying to compile cura for gentoo, and i have problem with this dependecie, when i try to compile i get this error
CMake Error at CMakeLists.txt:5 (find_package):
By not providing "Findnest2d.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "nest2d", but
CMake did not find one.
Could not find a package configuration file provided by "nest2d" with any
of the following names:
nest2dConfig.cmake
nest2d-config.cmake
Add the installation prefix of "nest2d" to CMAKE_PREFIX_PATH or set
"nest2d_DIR" to a directory containing one of the above files. If "nest2d"
provides a separate development package or SDK, be sure it has been
installed.
previous version had some sort of patch but it doesnt work for this version, i am not good at writing patches, can somebody help me with this out ?
https://bpa.st/Y6UZO <-this is the patch for ver 4.12.1 what is correct one for version 5.2.2?
I'm attempting to package pynest2d, which depends on your fork of libnest2d.
Please tag a release for libnest2d
thanks!
using the command
conan install . --build=missing --update
generate this error:
sipbuildtool/0.2.2@ultimaker/stable: ERROR: Traceback (most recent call last):
File "C:\Program Files\Python39\lib\site-packages\conans\client\generators\__init__.py", line 177, in write_generators
generator = generator_class(conanfile)
File "C:\Program Files\Python39\lib\site-packages\conan\tools\microsoft\msbuilddeps.py", line 95, in __init__
self.configuration = conanfile.settings.build_type
File "C:\Program Files\Python39\lib\site-packages\conans\model\settings.py", line 266, in __getattr__
self._check_field(field)
File "C:\Program Files\Python39\lib\site-packages\conans\model\settings.py", line 262, in _check_field
raise undefined_field(self._name, field, self.fields, self._parent_value)
conans.errors.ConanException: 'settings.build_type' doesn't exist
'settings' possible configurations are none
ERROR: Error in generator 'MSBuildDeps': 'settings.build_type' doesn't exist
'settings' possible configurations are none
Hi, a have a set of 5 polygons, but when I run the algorithm, some of the polygons overlaps in the transformed shape.
I checked also by using rotation() and translation() on the original polygons, but the result is same and still incorrect.
Also tried to offset them to be in the positive coordinates - no change of the output...
Any toughts what could be wrong?
Here is the list of the 5 polygons:
[Item([Point(216,-31),Point(176,-31),Point(136,-31),Point(136,-10),Point(136,24),Point(120,24),Point(108,24),Point(108,62),Point(108,100),Point(48,100),Point(-3,100),Point(-41,100),Point(-79,100),Point(-79,56),Point(-79,54),Point(-80,54),Point(-81,54),Point(-81,39),Point(-81,24),Point(-81,24),Point(-109,24),Point(-109,-10),Point(-109,-31),Point(-151,-31),Point(-193,-31),Point(-193,-108),Point(-193,-185),Point(11,-185),Point(216,-185),Point(216,-108)]),Item([Point(80,87),Point(80,99),Point(0,99),Point(-80,99),Point(-80,87),Point(-80,75),Point(-83,75),Point(-128,75),Point(-128,43),Point(-128,41),Point(-156,41),Point(-184,41),Point(-184,-61),Point(-184,-164),Point(-172,-164),Point(-160,-164),Point(0,-164),Point(160,-164),Point(172,-164),Point(184,-164),Point(184,-61),Point(184,41),Point(156,41),Point(128,41),Point(128,43),Point(128,75),Point(83,75),Point(80,75)]),Item([Point(-56,94),Point(-56,87),Point(-59,87),Point(-64,87),Point(-64,79),Point(-64,73),Point(-65,73),Point(-66,73),Point(-66,70),Point(-66,67),Point(-68,67),Point(-76,67),Point(-76,-54),Point(-76,-176),Point(-45,-176),Point(-38,-176),Point(-38,-198),Point(-38,-220),Point(36,-220),Point(111,-220),Point(111,-209),Point(111,-198),Point(111,-195),Point(111,-176),Point(111,-62),Point(111,51),Point(111,122),Point(111,133),Point(111,145),Point(111,157),Point(36,157),Point(-38,157),Point(-38,129),Point(-38,101),Point(-46,101),Point(-56,101)]),Item([Point(-74,-112),Point(-74,-177),Point(-23,-177),Point(3,-177),Point(60,-177),Point(117,-177),Point(117,-69),Point(117,18),Point(117,62),Point(117,106),Point(64,106),Point(11,106),Point(11,93),Point(11,86),Point(8,86),Point(5,86),Point(-26,86),Point(-58,86),Point(-58,76),Point(-58,66),Point(-59,66),Point(-64,66),Point(-64,9),Point(-64,-47),Point(-69,-47),Point(-74,-47)]),Item([Point(-81,117),Point(-88,117),Point(-95,117),Point(-95,15),Point(-95,-86),Point(-95,-97),Point(-95,-126),Point(-72,-126),Point(-49,-126),Point(-7,-126),Point(20,-126),Point(20,-157),Point(20,-188),Point(50,-188),Point(80,-188),Point(80,-156),Point(80,-124),Point(80,-102),Point(80,-70),Point(80,53),Point(80,141),Point(80,163),Point(80,185),Point(50,185),Point(20,185),Point(20,163),Point(20,141),Point(-18,141),Point(-81,141),Point(-81,123)])]
nest2d was changed to LGPL:
markfink/nest2D@4e6605d
Followed the building instructions, now am confused on how to import the module in to a project (or use in a venv).
From the cmake_install I can see the files go somewhere but 'conan build .' doesn't show where.
There are files in build\Release\site-packages which I assumed could just be copied over to the site-packages folder in the venv, that satisfies a pip show but still raises an import error.
I try to Nesting some random Items (100 rectangle of random size), and get this result:
But supposed to get something like this:
I use pynest2d.pyd from UltiMaker Cura 5.4.0.
main part of code related:
from pynest2d import *
volume = Box(2000, 2000)
config = NfpConfig()
config.accuracy = 1.0
# config.alignment = NfpConfig.Alignment.BOTTOM_LEFT
# config.alignment = NfpConfig.Alignment.BOTTOM_RIGHT
# config.alignment = NfpConfig.Alignment.CENTER
# config.alignment = NfpConfig.Alignment.DONT_ALIGN
config.alignment = NfpConfig.Alignment.TOP_LEFT
# config.alignment = NfpConfig.Alignment.TOP_RIGHT
# config.starting_point = NfpConfig.Alignment.BOTTOM_LEFT
# config.starting_point = NfpConfig.Alignment.BOTTOM_RIGHT
# config.starting_point = NfpConfig.Alignment.CENTER
# config.starting_point = NfpConfig.Alignment.DONT_ALIGN
config.starting_point = NfpConfig.Alignment.TOP_LEFT
# config.starting_point = NfpConfig.Alignment.TOP_RIGHT
spacing = 1
num_bins = nest(List_Items, volume, spacing, config)
Had tried all options of alignment, starting_point, get some strange result:
Getting an error on running conan install . --build=missing --update
make[2]: *** [src/x86/darwin.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
libffi/3.2.1:
libffi/3.2.1: ERROR: Package '240c2182163325b213ca6886a7614c8ed2bf1738' build failed
libffi/3.2.1: WARN: Build folder /Users/devdesign/.conan/data/libffi/3.2.1/_/_/build/240c2182163325b213ca6886a7614c8ed2bf1738
ERROR: libffi/3.2.1: Error in build() method, line 160
autotools.make()
ConanException: Error 2 while executing make -j10
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.