Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds plot method to Bin object. #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nmingotti
Copy link

I have added a simple way to plot a Bin and the contained Items. Besides being nice to see this should help highlight in which cases the algorithm is not working. I apologize If i made some mistakes this is my first pull request. bye

@nmingotti nmingotti changed the title Added plot method to object bin. Adds plot method to Bin object. Jun 11, 2021
@Thothore
Copy link

Thothore commented Dec 28, 2021

Any news ? It would be neat to have some integrated visualization @enzoruiz

@nobel6018
Copy link

nobel6018 commented Dec 14, 2022

@nmingotti Thank you for awesome feature.
I think it could be more useful if rotation is considered when plot the figure.

::::::::::: medium-2-box(13.625x11.875x3.375, max_weight:70.000) vol(546.064)
FITTED ITEMS:
====>  250g [powder 7](7.874x3.937x1.968, weight: 7.000) pos([0, 0, 0]) rt(0) vol(61.008)
====>  250g [powder 8](7.874x3.937x1.968, weight: 8.000) pos([Decimal('7.874'), 0, 0]) rt(1) vol(61.008)  // rt(1) rotation is true
====>  250g [powder 9](7.874x3.937x1.968, weight: 9.000) pos([0, Decimal('3.937'), 0]) rt(0) vol(61.008)
UNFITTED ITEMS:
***************************************************

But the figure doesn't consider it.
medium-2-box

The blue bin is not rotated.

The code I run is

from py3dbp import Packer, Bin, Item

packer = Packer()

packer.add_bin(Bin('small-envelope', 11.5, 6.125, 0.25, 10))
packer.add_bin(Bin('large-envelope', 15.0, 12.0, 0.75, 15))
packer.add_bin(Bin('small-box', 8.625, 5.375, 1.625, 70.0))
packer.add_bin(Bin('medium-box', 11.0, 8.5, 5.5, 70.0))
packer.add_bin(Bin('medium-2-box', 13.625, 11.875, 3.375, 70.0))
packer.add_bin(Bin('large-box', 12.0, 12.0, 5.5, 70.0))
packer.add_bin(Bin('large-2-box', 23.6875, 11.75, 3.0, 70.0))

packer.add_item(Item('50g [powder 1]', 3.9370, 1.9685, 1.9685, 1))
packer.add_item(Item('50g [powder 2]', 3.9370, 1.9685, 1.9685, 2))
packer.add_item(Item('50g [powder 3]', 3.9370, 1.9685, 1.9685, 3))
packer.add_item(Item('250g [powder 4]', 7.8740, 3.9370, 1.9685, 4))
packer.add_item(Item('250g [powder 5]', 7.8740, 3.9370, 1.9685, 5))
packer.add_item(Item('250g [powder 6]', 7.8740, 3.9370, 1.9685, 6))
packer.add_item(Item('250g [powder 7]', 7.8740, 3.9370, 1.9685, 7))
packer.add_item(Item('250g [powder 8]', 7.8740, 3.9370, 1.9685, 8))
packer.add_item(Item('250g [powder 9]', 7.8740, 3.9370, 1.9685, 9))

packer.pack(distribute_items=True)  // ✅ distribute_item=True

for bin in packer.bins:
    print(":::::::::::", bin.string())

    print("FITTED ITEMS:")
    for item in bin.items:
        print("====> ", item.string())

    print("UNFITTED ITEMS:")
    for item in bin.unfitted_items:
        print("====> ", item.string())

    bin.plotBoxAndItems(bin.name)
    print("***************************************************\n\n")

jurgensega pushed a commit to NSIT/abap-3dbinpacking that referenced this pull request May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants