Closed lettore closed 1 year ago
This is the contents of printer.exclude_object.objects
printer.exclude_object.objects : [{'name': '0'}, {'name': '1'}, {'name': 'ENDGCODE'}, {'center': [112.5, 99.5], 'polygon': [[102.71, 89.71], [102.71, 109.29], [122.29, 109.29], [122.29, 89.71], [102.71, 89.71]], 'name': 'TEST_M10_STL_ID_0_COPY_0'}, {'center': [112.5, 125.456], 'polygon': [[110.442, 115.5], [102.71, 115.71], [102.71, 135.29], [114.623, 135.412], [122.29, 135.29], [122.29, 115.71], [110.442, 115.5]], 'name': 'TEST_M10_STL_ID_1_COPY_0'}]
Hm... hadn't occurred to me that something like EXCLUDE_OBJECT_DEFINE NAME=ENDGCODE
would produce an objects
entry. It's an easy fix though; just needs a selectattr('polygon')
filter. I'll land it with some other changes in the next day or so, but here's the diff:
diff --git a/start_end.cfg b/start_end.cfg
index 49f431d..8031702 100644
--- a/start_end.cfg
+++ b/start_end.cfg
@@ -445,8 +445,8 @@ gcode:
{% set points = [MODEL_MIN, MODEL_MAX] %}
{% endif %}
{% if (printer.exclude_object|default({})).objects %}
- {% set points = printer.exclude_object.objects|map(attribute='polygon')|
- sum(start=points) %}
+ {% set points = printer.exclude_object.objects|selectattr('polygon')|
+ map(attribute='polygon')|sum(start=points) %}
{% set points_len = points|length %}
{% if points_len >= 2 %}
{% set x_coords = (points|map(attribute=0)|sort|list)[0::points_len-1] %}
I found the problem, if the Gcode is exported as is Superslicer or Prusaslicer labels the objects but there's no polygon variable in the object.
I used the postprocessing tool from https://github.com/kageurufu/preprocess_cancellation and this adds the polygon section but it not removes the "legacy" objects, and it also adds an ENDGCODE empty object.
The correct way to load the prints it's to add enable_object_processing: True
in [file_manager] section of moonraker.conf and NOT do any postprocess in slicer.
In this way the objects are populated with the polygon section.
But yes dealing with empty objects it's correct.
Fixed in 8aa2e47b920c8824888e8a7c8f131b99922c7d6f.
Starting a print with
variable_start_random_placement_max: 100
returnsError evaluating 'gcode_macro _km_check_and_set_print_bounds:gcode': UndefinedError: 'dict object' has no attribute 'polygon'
This is the GCODEAt the moment I managed to make work random placement skipping the exclude object section if it's provided MODEL_MIN and MODEL_MAX.