Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'magic_uv/op/uvw.py')
-rw-r--r--magic_uv/op/uvw.py45
1 files changed, 16 insertions, 29 deletions
diff --git a/magic_uv/op/uvw.py b/magic_uv/op/uvw.py
index fca72d2c..42918dd5 100644
--- a/magic_uv/op/uvw.py
+++ b/magic_uv/op/uvw.py
@@ -20,8 +20,8 @@
__author__ = "Alexander Milovsky, Nutti <nutti.metro@gmail.com>"
__status__ = "production"
-__version__ = "6.3"
-__date__ = "10 Aug 2020"
+__version__ = "6.4"
+__date__ = "23 Oct 2020"
from math import sin, cos, pi
@@ -41,21 +41,16 @@ from ..utils import compatibility as compat
def _is_valid_context(context):
- obj = context.object
+ objs = common.get_uv_editable_objects(context)
+ if not objs:
+ return False
# only edit mode is allowed to execute
- if obj is None:
- return False
- if obj.type != 'MESH':
- return False
if context.object.mode != 'EDIT':
return False
# only 'VIEW_3D' space is allowed to execute
- for space in context.area.spaces:
- if space.type == 'VIEW_3D':
- break
- else:
+ if not common.is_valid_space(context, ['VIEW_3D']):
return False
return True
@@ -228,15 +223,11 @@ class MUV_OT_UVW_BoxMap(bpy.types.Operator):
return True
return _is_valid_context(context)
- def execute(self, _):
- if compat.check_version(2, 80, 0) < 0:
- objs = [bpy.context.active_object]
- else:
- objs = [o for o in bpy.data.objects
- if compat.get_object_select(o) and o.type == 'MESH']
+ def execute(self, context):
+ objs = common.get_uv_editable_objects(context)
- for o in objs:
- bm = bmesh.from_edit_mesh(o.data)
+ for obj in objs:
+ bm = bmesh.from_edit_mesh(obj.data)
if common.check_version(2, 73, 0) >= 0:
bm.faces.ensure_lookup_table()
@@ -247,7 +238,7 @@ class MUV_OT_UVW_BoxMap(bpy.types.Operator):
_apply_box_map(bm, uv_layer, self.size, self.offset, self.rotation,
self.tex_aspect)
- bmesh.update_edit_mesh(o.data)
+ bmesh.update_edit_mesh(obj.data)
return {'FINISHED'}
@@ -291,15 +282,11 @@ class MUV_OT_UVW_BestPlanerMap(bpy.types.Operator):
return True
return _is_valid_context(context)
- def execute(self, _):
- if compat.check_version(2, 80, 0) < 0:
- objs = [bpy.context.active_object]
- else:
- objs = [o for o in bpy.data.objects
- if compat.get_object_select(o) and o.type == 'MESH']
+ def execute(self, context):
+ objs = common.get_uv_editable_objects(context)
- for o in objs:
- bm = bmesh.from_edit_mesh(o.data)
+ for obj in objs:
+ bm = bmesh.from_edit_mesh(obj.data)
if common.check_version(2, 73, 0) >= 0:
bm.faces.ensure_lookup_table()
@@ -311,6 +298,6 @@ class MUV_OT_UVW_BestPlanerMap(bpy.types.Operator):
_apply_planer_map(bm, uv_layer, self.size, self.offset,
self.rotation, self.tex_aspect)
- bmesh.update_edit_mesh(o.data)
+ bmesh.update_edit_mesh(obj.data)
return {'FINISHED'}