diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-06-11 12:06:43 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-06-11 12:06:43 +0300 |
commit | 4ac87d58eb8d0dd6cb9d4a857c8b5aca4c7abb64 (patch) | |
tree | f35d268add2f5c770b1f7b3dbb38098cf442c9b1 /release/scripts/startup/bl_operators/uvcalc_lightmap.py | |
parent | b6be8c03942bc254921117e77e406ca225a47aa7 (diff) | |
parent | 28c34ae7e2d61d0b1c570b7d9a303267404e54be (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'release/scripts/startup/bl_operators/uvcalc_lightmap.py')
-rw-r--r-- | release/scripts/startup/bl_operators/uvcalc_lightmap.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/release/scripts/startup/bl_operators/uvcalc_lightmap.py b/release/scripts/startup/bl_operators/uvcalc_lightmap.py index 61ceb3c04c4..ff7bab4102a 100644 --- a/release/scripts/startup/bl_operators/uvcalc_lightmap.py +++ b/release/scripts/startup/bl_operators/uvcalc_lightmap.py @@ -559,12 +559,24 @@ def lightmap_uvpack(meshes, def unwrap(operator, context, **kwargs): - is_editmode = (context.object.mode == 'EDIT') + # only unwrap active object if True + PREF_ACT_ONLY = kwargs.pop("PREF_ACT_ONLY") + + # ensure object(s) are selected if necessary and active object is set + if context.object is None: + if PREF_ACT_ONLY: + operator.report({'WARNING'}, "Active object not set") + return {'CANCELLED'} + elif len(context.selected_objects) == 0: + operator.report({'WARNING'}, "No selected objects") + return {'CANCELLED'} + + # switch to object mode + is_editmode = context.object and context.object.mode == 'EDIT' if is_editmode: bpy.ops.object.mode_set(mode='OBJECT', toggle=False) - PREF_ACT_ONLY = kwargs.pop("PREF_ACT_ONLY") - + # define list of meshes meshes = [] if PREF_ACT_ONLY: obj = context.scene.objects.active @@ -579,6 +591,7 @@ def unwrap(operator, context, **kwargs): lightmap_uvpack(meshes, **kwargs) + # switch back to edit mode if is_editmode: bpy.ops.object.mode_set(mode='EDIT', toggle=False) |