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:
authorNutti <nutti.metro@gmail.com>2018-11-17 15:11:55 +0300
committerNutti <nutti.metro@gmail.com>2018-11-17 15:11:55 +0300
commit2532b96844c121b710e1a1973d2a5ff824ab3be4 (patch)
treec1f7682a77310f53ed4c2682b0788f73aa677d69 /uv_magic_uv/op/unwrap_constraint.py
parent92ebf635ee2a9ddbc7fbf4a0c06b9732ee555b27 (diff)
Magic UV: Release v5.2
* Bulit-in menu preferences * Add-on updater * Copy/Paste UV * Add option "[New]" for pasting to newly allocated UV map * Add option "[All]" for pasting all UV maps at once * Align UV * Add option "Mesh Influence" * World Scale UV * Add mode option "Manual" to allow the user specify the density manually * Improve UI * Cleanup documents * Fix bugs
Diffstat (limited to 'uv_magic_uv/op/unwrap_constraint.py')
-rw-r--r--uv_magic_uv/op/unwrap_constraint.py68
1 files changed, 64 insertions, 4 deletions
diff --git a/uv_magic_uv/op/unwrap_constraint.py b/uv_magic_uv/op/unwrap_constraint.py
index e98879b7..b2368fc4 100644
--- a/uv_magic_uv/op/unwrap_constraint.py
+++ b/uv_magic_uv/op/unwrap_constraint.py
@@ -18,8 +18,8 @@
__author__ = "Nutti <nutti.metro@gmail.com>"
__status__ = "production"
-__version__ = "5.1"
-__date__ = "24 Feb 2018"
+__version__ = "5.2"
+__date__ = "17 Nov 2018"
import bpy
import bmesh
@@ -32,12 +32,65 @@ from bpy.props import (
from .. import common
-class MUV_UnwrapConstraint(bpy.types.Operator):
+__all__ = [
+ 'Properties',
+ 'Operator',
+]
+
+
+def is_valid_context(context):
+ obj = context.object
+
+ # 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:
+ return False
+
+ return True
+
+
+class Properties:
+ @classmethod
+ def init_props(cls, scene):
+ scene.muv_unwrap_constraint_enabled = BoolProperty(
+ name="Unwrap Constraint Enabled",
+ description="Unwrap Constraint is enabled",
+ default=False
+ )
+ scene.muv_unwrap_constraint_u_const = BoolProperty(
+ name="U-Constraint",
+ description="Keep UV U-axis coordinate",
+ default=False
+ )
+ scene.muv_unwrap_constraint_v_const = BoolProperty(
+ name="V-Constraint",
+ description="Keep UV V-axis coordinate",
+ default=False
+ )
+
+ @classmethod
+ def del_props(cls, scene):
+ del scene.muv_unwrap_constraint_enabled
+ del scene.muv_unwrap_constraint_u_const
+ del scene.muv_unwrap_constraint_v_const
+
+
+class Operator(bpy.types.Operator):
"""
Operation class: Unwrap with constrain UV coordinate
"""
- bl_idname = "uv.muv_unwrap_constraint"
+ bl_idname = "uv.muv_unwrap_constraint_operator"
bl_label = "Unwrap Constraint"
bl_description = "Unwrap while keeping uv coordinate"
bl_options = {'REGISTER', 'UNDO'}
@@ -83,6 +136,13 @@ class MUV_UnwrapConstraint(bpy.types.Operator):
default=False
)
+ @classmethod
+ def poll(cls, context):
+ # we can not get area/space/region from console
+ if common.is_console_mode():
+ return True
+ return is_valid_context(context)
+
def execute(self, _):
obj = bpy.context.active_object
bm = bmesh.from_edit_mesh(obj.data)