Giter Club home page Giter Club logo

Comments (8)

jindili avatar jindili commented on September 25, 2024

After search through Google and Github, I try Ask Claude AI
https://claude.ai/
Q: use libnest2d to nesting 100 random rectrangle, the nesting result is a circle, but supposed to nest in a rectangle shape, help me debug

A:
There are a few things that could cause the nesting result to be a circle rather than a rectangle when using libnest2d to nest 100 random rectangles:

  • The bounding box is not being set correctly - libnest2d will nest shapes within the bounding box provided. Make sure you are setting an appropriate rectangular bounding box, not a circular one.

  • Shapes are being rotated - libnest2d will rotate shapes to find the optimal nesting. If you don't want rotation, disable it with the no_rotation option.

  • Order of input shapes - Try changing the order of the input rectangle list to get different nesting output. Some orders may lend better to a circular result.

  • Not enough space for proper nesting - If the bounding box is too small to fit all the rectangles efficiently, it may result in a circular-looking layout. Try increasing the bounding box size.

  • Bad initial placement - The initial placement seed can affect nesting. Try changing the config place_seeds option.

  • Sub-optimal packing algorithm - Libnest2d has different packing algorithms. Test different ones like bottom-left or contact-point to see if it improves the rectilinear nesting.

To properly debug, I would start by printing out the bounding box coordinates and enabling visual output to see exactly what is happening. Also try nesting just a few rectangles first to check the baseline behavior. With some targeted debugging and experimentation, you should be able to get the desired rectangular nesting.

from pynest2d.

jindili avatar jindili commented on September 25, 2024

Trying PrusaSlicer-2.6.0
seems arrange Items in circle is the default behavior
image

from pynest2d.

jindili avatar jindili commented on September 25, 2024

and it's the default arrange behavior of Cura 5.4
image

from pynest2d.

jindili avatar jindili commented on September 25, 2024

Come across a similar question on libnest2d:

Strange "starting_point" behavior in NfpPlacer · Issue #52 · tamasmeszaros/libnest2d
tamasmeszaros/libnest2d#52

from pynest2d.

jindili avatar jindili commented on September 25, 2024

try nest() with BottomLeft Placer

config_rect = BottomLeftConfig()
config_rect.allow_rotations = False
num_bins = nest(List_Items, volume, spacing, config_rect)

get this error

TypeError: nest(): argument 4 has unexpected type 'BottomLeftConfig'

help(nest)

Help on built-in function nest in module pynest2d:
nest(...)
    Arrange a number of items in bins, packing them closely with the goal to
    minimise the number of bins necessary to pack all given items.
    
    This function uses the FirstFit selector and NfpPPlacer in its algorithms,
    and Clipper as geometry back-end.
    
    The result of the packing is stored in the transformation of the input
    items. You can get the transformed items by calling transformedShape() on
    each of the items, or by looking at their rotation and translation. Items
    may also be placed on alternative bins if the first bin is not big enough to
    fit all items.
    :param items: An iterable of Item instances which are the items that need to
    be placed in the bins.
    :param bin: The shape in which to place these items.
    :param distance: (Default 1.) The distance to hold between adjacent items in
    the final pack result. Items will not get placed closer than this distance.
    Must be at least 1 unit.
    :param config: An NfpConfig instance that contains configuration options to
    specialize how objects get placed. Defaults will be used if this is not
    provided.
    :return: The number of bins necessary to fit all items.

:param config: An NfpConfig instance that contains configuration options

seems only NfpConfig is supported.

from pynest2d.

jindili avatar jindili commented on September 25, 2024

look into source code of libnest2d, seems BottomLeftPlacer is implemented as well.

libnest2d/src/libnest2d.cpp at 359d71fb4e5a951c17228f4be75b432187ca4993 · Ultimaker/libnest2d
https://github.com/Ultimaker/libnest2d/blob/359d71fb4e5a951c17228f4be75b432187ca4993/src/libnest2d.cpp

image

from pynest2d.

jindili avatar jindili commented on September 25, 2024

[Doubt] - Using BottomLeftConfig · Issue #25 · Ultimaker/pynest2d
#25

from pynest2d.

jindili avatar jindili commented on September 25, 2024

So to use BottomLeftPlacer, seems I have to change some code and build a new pynest2d.pyd

image

pynest2d/python/pynest2d.sip at main · Ultimaker/pynest2d
https://github.com/Ultimaker/pynest2d/blob/main/python/pynest2d.sip

from pynest2d.

Related Issues (14)

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.