Registry / data / rectpack

rectpack

JSON →
library0.2.2pypypi✓ verified 82d ago

A Python library for packing 2D rectangles into a bin using various algorithms (MaxRects, Guillotine, etc.). Supports rotation, sorting, and multiple packing modes. Current version 0.2.2, maintained infrequently.

pip install rectpack
INSTALL
IMPORT
SIG · RECTPACK
R
rectpack
datapythonv0.2.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GuillotineBafLas
from rectpack import GuillotineBafLas
from rectpack import Packer
MaxRectsBaf
from rectpack import MaxRectsBaf
from rectpack import Packer
GuillotineBssfSlas
from rectpack import GuillotineBssfSlas
from rectpack import Packer

Basic packing of two rectangles into a 100x100 bin using MaxRects BSSF algorithm.

from rectpack import Packer, MaxRectsBssf from rectpack import SORT_AREA packer = Packer() # Use a packing algorithm packer.add_bin(100, 100) packer.add_rect(50, 30, rid='rect1') packer.add_rect(20, 40, rid='rect2') packer.pack_algo = MaxRectsBssf() packer.sort_algo = SORT_AREA packer.pack() for rect in packer.rect_list(): print('Rectangle:', rect) # Alternatively, get a summary print('Bins:', packer.bins) # list of Bin objects print('Unpacked:', packer.unused_areas())
Debug
Known issues
gotchaThe library does not check if a rectangle fits before packing. If no bin can accommodate, the rectangle is silently left unpacked. Always check packer.rect_list() against your input.
fix
After packing, iterate packer.rect_list() and compare with input counts to detect unplaced rectangles.
affects: all
deprecatedThe attribute 'pack_algo' is being replaced by 'pack_algo' usage as a property. In older examples, they assigned the algorithm class directly; now use an instance.
fix
Use: packer.pack_algo = MaxRectsBssf() (with parentheses)
affects: <0.2.0
gotchaRectangles added without 'rid' will be assigned a default id (e.g., 'rect_0'). If multiple rectangles have the same rid, later ones overwrite earlier ones in internal dictionary. Use unique rid per rectangle to avoid data loss.
fix
Always provide unique rid strings, e.g., f'rect_{i}'.
affects: all
Upgrade
Version history
0.2.2latest on PyPI · released Nov 24, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
rectpack — pip install rectpack · libregistry