-
Notifications
You must be signed in to change notification settings - Fork 10
Description
I am encountering an AttributeError when using optimiser.addShapeAsHole(). The error indicates that the Polygon object being processed does not have the shape_nfps attribute, suggesting it's a standard shapely.geometry.Polygon object rather than the extended WasteOptimiser Polygon class.
Full Traceback:
File "c:\Users\francesco.tripaldi\Desktop\dxf2gcode\nest_dialog.py", line 169, in run_nesting
placements = self.run_nesting_from_contours(self.contours)
File "c:\Users\francesco.tripaldi\Desktop\dxf2gcode\nest_dialog.py", line 130, in run_nesting_from_contours
self.api.placeAllSelectedShapes()
File "c:\Users\francesco.tripaldi\Desktop\dxf2gcode\WasteOptimiser\wasteoptimiser\api\api.py", line 114, in placeAllSelectedShapes
if not self.placeSelectedShape():
File "c:\Users\francesco.tripaldi\Desktop\dxf2gcode\WasteOptimiser\wasteoptimiser\api\api.py", line 98, in placeSelectedShape
self.optimiser.addShapeAsHole(self.selected_shape_name)
File "c:\Users\francesco.tripaldi\Desktop\dxf2gcode\WasteOptimiser\wasteoptimiser\optimiser\spaceoptimiser.py", line 262, in addShapeAsHole
newhole.shape_nfps = defaultdict()
AttributeError: 'Polygon' object has no attribute 'shape_nfps'
(Note: Line number 262 is where the attribute assignment is attempted.)
Steps to Reproduce:
Initialize the WasteOptimiser API.
Attempt to place shapes using self.api.placeAllSelectedShapes() or directly call self.optimiser.addShapeAsHole() with any valid shape.
Expected Behavior:
The addShapeAsHole method should successfully process the shape, and the newhole object should be an instance of the custom WasteOptimiser Polygon class, possessing the shape_nfps attribute.
Actual Behavior:
An AttributeError occurs because the newhole object is a standard shapely.geometry.Polygon, which lacks the shape_nfps attribute. This happens even when self.optimiser.convex_hull is set to False, indicating a more fundamental issue with the Polygon object instantiation within WasteOptimiser.
Environment:
Operating System: Windows11
Python Version: 3.8.7, 3.9.13, 3.11.9, 3.13.8
Thank you for your time.