diff options
-rw-r--r-- | release/scripts/startup/bl_operators/object.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/release/scripts/startup/bl_operators/object.py b/release/scripts/startup/bl_operators/object.py index 98d3d0c8c6d..f68ebfc4b94 100644 --- a/release/scripts/startup/bl_operators/object.py +++ b/release/scripts/startup/bl_operators/object.py @@ -869,6 +869,7 @@ class DupliOffsetFromCursor(Operator): return {'FINISHED'} + class LoadImageAsEmpty(Operator): """Select an image file and create a new image empty with it""" bl_idname = "object.load_image_as_empty" @@ -887,13 +888,16 @@ class LoadImageAsEmpty(Operator): return {'RUNNING_MODAL'} def execute(self, context): + scene = context.scene + space = context.space_data + cursor = (space if space and space.type == 'VIEW_3D' else scene).cursor_location try: image = bpy.data.images.load(self.filepath, check_existing=True) - except RuntimeError: - self.report({"ERROR"}, "cannot load image") + except RuntimeError as ex: + self.report({"ERROR"}, str(ex)) return {"CANCELLED"} - bpy.ops.object.empty_add(type='IMAGE', location=context.scene.cursor_location) + bpy.ops.object.empty_add(type='IMAGE', location=cursor) context.active_object.data = image return {'FINISHED'} |