Просмотр исходного кода

Don't crash when loading model before a printer is loaded

The model won't load successfully and you get a message that it failed to load, but Cura won't crash at least.

Contributes to issue CURA-4736.
Ghostkeeper 7 лет назад
Родитель
Сommit
4a3109c885
2 измененных файлов с 4 добавлено и 5 удалено
  1. 1 1
      cura/CuraApplication.py
  2. 3 4
      cura/ShapeArray.py

+ 1 - 1
cura/CuraApplication.py

@@ -1387,7 +1387,7 @@ class CuraApplication(QtApplication):
 
             if node.callDecoration("isSliceable"):
                 # Only check position if it's not already blatantly obvious that it won't fit.
-                if node.getBoundingBox().width < self._volume.getBoundingBox().width or node.getBoundingBox().depth < self._volume.getBoundingBox().depth:
+                if node.getBoundingBox() is None or self._volume.getBoundingBox() is None or node.getBoundingBox().width < self._volume.getBoundingBox().width or node.getBoundingBox().depth < self._volume.getBoundingBox().depth:
                     # Find node location
                     offset_shape_arr, hull_shape_arr = ShapeArray.fromNode(node, min_offset = min_offset)
 

+ 3 - 4
cura/ShapeArray.py

@@ -43,13 +43,12 @@ class ShapeArray:
         transform_x = transform._data[0][3]
         transform_y = transform._data[2][3]
         hull_verts = node.callDecoration("getConvexHull")
+        # If a model is too small then it will not contain any points
+        if hull_verts is None or not hull_verts.getPoints().any():
+            return None, None
         # For one_at_a_time printing you need the convex hull head.
         hull_head_verts = node.callDecoration("getConvexHullHead") or hull_verts
 
-        # If a model is to small then it will not contain any points
-        if not hull_verts.getPoints().any():
-            return None, None
-
         offset_verts = hull_head_verts.getMinkowskiHull(Polygon.approximatedCircle(min_offset))
         offset_points = copy.deepcopy(offset_verts._points)  # x, y
         offset_points[:, 0] = numpy.add(offset_points[:, 0], -transform_x)