[Bf-blender-cvs] [d9f6fdae4b5] blender2.8: Add Image Operator: minor tweaks
Campbell Barton
noreply at git.blender.org
Sun Sep 30 09:59:44 CEST 2018
Commit: d9f6fdae4b5ae0475f0cbc8114a87b3be21739db
Author: Campbell Barton
Date: Sun Sep 30 17:55:39 2018 +1000
Branches: blender2.8
https://developer.blender.org/rBd9f6fdae4b5ae0475f0cbc8114a87b3be21739db
Add Image Operator: minor tweaks
- Use exception message on error.
- Use 3D view cursor location (for local view).
===================================================================
M release/scripts/startup/bl_operators/object.py
===================================================================
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'}
More information about the Bf-blender-cvs
mailing list