printrun-src/printrun/gcodeplater.py

changeset 46
cce0af6351f0
parent 15
0bbb006204fc
--- a/printrun-src/printrun/gcodeplater.py	Tue Jan 19 20:45:09 2021 +0100
+++ b/printrun-src/printrun/gcodeplater.py	Wed Jan 20 10:15:13 2021 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 # This file is part of the Printrun suite.
 #
@@ -79,17 +79,20 @@
 
     def prepare_ui(self, filenames = [], callback = None,
                    parent = None, build_dimensions = None,
-                   circular_platform = False, antialias_samples = 0):
+                   circular_platform = False,
+                   antialias_samples = 0,
+                   grid = (1, 10)):
         super(GcodePlaterPanel, self).prepare_ui(filenames, callback, parent, build_dimensions)
         viewer = gcview.GcodeViewPanel(self, build_dimensions = self.build_dimensions,
                                        antialias_samples = antialias_samples)
         self.set_viewer(viewer)
         self.platform = actors.Platform(self.build_dimensions,
-                                        circular = circular_platform)
+                                        circular = circular_platform,
+                                        grid = grid)
         self.platform_object = gcview.GCObject(self.platform)
 
     def get_objects(self):
-        return [self.platform_object] + self.models.values()
+        return [self.platform_object] + list(self.models.values())
     objects = property(get_objects)
 
     def load_file(self, filename):
@@ -99,9 +102,9 @@
         if gcode.filament_length > 0:
             model.display_travels = False
         generator = model.load_data(gcode)
-        generator_output = generator.next()
+        generator_output = next(generator)
         while generator_output is not None:
-            generator_output = generator.next()
+            generator_output = next(generator)
         obj = gcview.GCObject(model)
         obj.offsets = [self.build_dimensions[3], self.build_dimensions[4], 0]
         obj.gcode = gcode
@@ -142,7 +145,7 @@
         return self.export_sequential(name)
 
     def export_combined(self, name):
-        models = self.models.values()
+        models = list(self.models.values())
         last_real_position = None
         # Sort models by Z max to print smaller objects first
         models.sort(key = lambda x: x.dims[-1])
@@ -151,7 +154,7 @@
             def add_offset(layer):
                 return layer.z + model.offsets[2] if layer.z is not None else layer.z
             alllayers += [(add_offset(layer), model_i, layer_i)
-                          for (layer_i, layer) in enumerate(model.gcode.all_layers) if layer]
+                          for (layer_i, layer) in enumerate(model.gcode.all_layers) if add_offset(layer) is not None]
         alllayers.sort()
         laste = [0] * len(models)
         lasttool = [0] * len(models)
@@ -196,7 +199,7 @@
         logging.info(_("Exported merged G-Codes to %s") % name)
 
     def export_sequential(self, name):
-        models = self.models.values()
+        models = list(self.models.values())
         last_real_position = None
         # Sort models by Z max to print smaller objects first
         models.sort(key = lambda x: x.dims[-1])
@@ -223,7 +226,7 @@
                         else:
                             f.write(rewrite_gline(co, l, math.cos(r), math.sin(r)) + "\n")
                 # Find the current real position
-                for i in xrange(len(model.gcode) - 1, -1, -1):
+                for i in range(len(model.gcode) - 1, -1, -1):
                     gline = model.gcode.lines[i]
                     if gline.is_move:
                         last_real_position = (- trans[0] + gline.current_x,

mercurial