@@ -207,6 +207,19 @@ def draw_dwells(self, dwells, alpha, for_selection, j0=0):
207207 return linuxcnc .draw_dwells (self .geometry , dwells , alpha , for_selection , self .is_lathe ())
208208
209209 def calc_extents (self ):
210+ # in the event of a "blank" gcode file (M2 only for example) this sets each of the extents to [0,0,0]
211+ # to prevent passing the very large [9e99,9e99,9e99] values and populating the gcode properties with
212+ # unusably large values. Some screens use the extents information to set the view distance so 0 values are preferred.
213+ if not self .arcfeed and not self .feed and not self .traverse :
214+ self .min_extents = \
215+ self .max_extents = \
216+ self .min_extents_notool = \
217+ self .max_extents_notool = \
218+ self .min_extents_zero_rxy = \
219+ self .max_extents_zero_rxy = \
220+ self .min_extents_notool_zero_rxy = \
221+ self .max_extents_notool_zero_rxy = [0 ,0 ,0 ]
222+ return
210223 self .min_extents , self .max_extents , self .min_extents_notool , self .max_extents_notool = gcode .calc_extents (self .arcfeed , self .feed , self .traverse )
211224 self .unrotate_preview ()
212225 self .min_extents_zero_rxy , self .max_extents_zero_rxy , self .min_extents_notool_zero_rxy , self .max_extents_notool_zero_rxy = gcode .calc_extents (self .preview_zero_rxy )
@@ -221,8 +234,8 @@ def calc_extents(self):
221234 self .max_extents_notool [0 ], self .max_extents_notool [1 ], max_z
222235
223236 # unrotates the current preview points defined by self.feed, self.arcfeed, self.traverse
224- # and populates self.preview_zero_rxy. Because this is only used to calculate the extents
225- # and not to draw to the screen, this can all be contained in the same list.
237+ # by the current rotation_xy amount and populates self.preview_zero_rxy. Because this is
238+ # only used to calculate the extents and not to draw to the screen, this can all be contained in the same list.
226239 def unrotate_preview (self ):
227240 angle = math .radians (- self .rotation_xy )
228241 cos = math .cos (angle )
0 commit comments