fixed crashes if bad object selections are made

pull/224/head^2
Joe Marshall 2023-01-11 15:29:25 +00:00
rodzic 4819311b3a
commit fca43ec45d
4 zmienionych plików z 14 dodań i 7 usunięć

Wyświetl plik

@ -0,0 +1,2 @@
class CamException(Exception):
pass

Wyświetl plik

@ -12,6 +12,7 @@ from io_mesh_stl import blender_utils
import mathutils
import math
from cam.simple import activate
from cam.exception import *
OCL_SCALE = 1000.0
@ -32,8 +33,7 @@ def get_oclSTL(operation):
oclSTL.addTriangle(t)
# FIXME needs to work with collections
if not found_mesh:
operation.operator.report({'ERROR_INVALID_INPUT'},"This operation requires a mesh object")
return None
raise CamException("This operation requires a mesh or curve object or equivalent (e.g. text, volume).")
return oclSTL

Wyświetl plik

@ -32,7 +32,7 @@ import shapely
import mathutils
import math
import cam
from cam.exception import *
class threadCom: # object passed to threads to read background process stdout info
def __init__(self, o, proc):
@ -201,7 +201,7 @@ class CalculatePath(bpy.types.Operator):
if not o.valid:
self.report({'ERROR_INVALID_INPUT'}, "Operation can't be performed, see warnings for info")
print("Operation can't be performed, see warnings for info")
return {'FINISHED'}
return {'CANCELLED'}
if o.computing:
return {'FINISHED'}
@ -210,8 +210,11 @@ class CalculatePath(bpy.types.Operator):
if o.use_layers:
o.parallel_step_back = False
gcodepath.getPath(context, o)
try:
gcodepath.getPath(context, o)
except CamException as e:
self.report({'ERROR'},str(e))
return {'CANCELLED'}
coll = bpy.data.collections.get('RigidBodyWorld')
if coll:
bpy.data.collections.remove(coll)

Wyświetl plik

@ -40,6 +40,7 @@ from cam.simple import *
from cam.pattern import *
from cam.polygon_utils_cam import *
from cam.image_utils import *
from cam.exception import *
from cam.opencamlib.opencamlib import oclSample, oclSamplePoints, oclResampleChunks, oclGetWaterline
@ -133,7 +134,8 @@ def getBoundsWorldspace(obs, use_modifiers=False):
bpy.ops.object.delete()
bpy.ops.outliner.orphans_purge()
else:
if not hasattr(ob.data,"splines"):
raise CamException("Can't do CAM operation on the selected object type")
# for coord in bb:
for c in ob.data.splines:
for p in c.bezier_points: