[Bf-extensions-cvs] [6be7451] master: Add-on: Copy/Paste UVs
nutti
noreply at git.blender.org
Fri Aug 7 14:28:52 CEST 2015
Commit: 6be74515683372e0369240fff9bdcb93fc7a2412
Author: nutti
Date: Fri Aug 7 21:26:38 2015 +0900
Branches: master
https://developer.blender.org/rBAC6be74515683372e0369240fff9bdcb93fc7a2412
Add-on: Copy/Paste UVs
Update to v3.2.
Improve feature: Transfer UV
- Improve algorithm
- Copy/Paste to multiple meshes
- Partially copy/paste UV
===================================================================
M uv_copy_and_paste_uv/__init__.py
M uv_copy_and_paste_uv/cpuv_common.py
M uv_copy_and_paste_uv/cpuv_default_operation.py
M uv_copy_and_paste_uv/cpuv_fliprot_operation.py
M uv_copy_and_paste_uv/cpuv_menu.py
M uv_copy_and_paste_uv/cpuv_properties.py
M uv_copy_and_paste_uv/cpuv_selseq_operation.py
M uv_copy_and_paste_uv/cpuv_transfer_uv_operation.py
M uv_copy_and_paste_uv/cpuv_uvmap_operation.py
===================================================================
diff --git a/uv_copy_and_paste_uv/__init__.py b/uv_copy_and_paste_uv/__init__.py
index 0386edf..e42f349 100644
--- a/uv_copy_and_paste_uv/__init__.py
+++ b/uv_copy_and_paste_uv/__init__.py
@@ -20,13 +20,13 @@
__author__ = "Nutti <nutti.metro at gmail.com>"
__status__ = "production"
-__version__ = "3.0"
-__date__ = "15 Jun 2015"
+__version__ = "3.2"
+__date__ = "20 Jun 2015"
bl_info = {
"name": "Copy and Paste UV",
"author": "Nutti",
- "version": (3, 0),
+ "version": (3, 2),
"blender": (2, 73, 0),
"location": "UV Mapping > Copy and Paste UV",
"description": "Copy and Paste UV data",
@@ -58,7 +58,6 @@ else:
from . import cpuv_transfer_uv_operation
import bpy
-from . import debug
# registration
@@ -71,7 +70,6 @@ def register():
bpy.utils.register_module(__name__)
bpy.types.VIEW3D_MT_uv_map.append(menu_fn)
bpy.types.Scene.cpuv_props = cpuv_properties.CPUVProperties()
- debug.start_debug()
def unregister():
diff --git a/uv_copy_and_paste_uv/cpuv_common.py b/uv_copy_and_paste_uv/cpuv_common.py
index 434e349..0ea1396 100644
--- a/uv_copy_and_paste_uv/cpuv_common.py
+++ b/uv_copy_and_paste_uv/cpuv_common.py
@@ -21,15 +21,21 @@
import bpy
import bmesh
from collections import namedtuple
+from . import cpuv_properties
__author__ = "Nutti <nutti.metro at gmail.com>"
__status__ = "production"
-__version__ = "3.0"
-__date__ = "15 Jun 2015"
+__version__ = "3.2"
+__date__ = "20 Jun 2015"
SelectedFaceInfo = namedtuple('SelectedFaceInfo', 'normal indices center')
+def debug_print(*s):
+ if cpuv_properties.DEBUG:
+ print(s)
+
+
class View3DModeMemory():
__mode_orig = None
diff --git a/uv_copy_and_paste_uv/cpuv_default_operation.py b/uv_copy_and_paste_uv/cpuv_default_operation.py
index 00d83c3..471aec9 100644
--- a/uv_copy_and_paste_uv/cpuv_default_operation.py
+++ b/uv_copy_and_paste_uv/cpuv_default_operation.py
@@ -24,8 +24,8 @@ from . import cpuv_common
__author__ = "Nutti <nutti.metro at gmail.com>"
__status__ = "production"
-__version__ = "3.0"
-__date__ = "15 Jun 2015"
+__version__ = "3.2"
+__date__ = "20 Jun 2015"
# copy UV
diff --git a/uv_copy_and_paste_uv/cpuv_fliprot_operation.py b/uv_copy_and_paste_uv/cpuv_fliprot_operation.py
index 9776e3a..5455cbc 100644
--- a/uv_copy_and_paste_uv/cpuv_fliprot_operation.py
+++ b/uv_copy_and_paste_uv/cpuv_fliprot_operation.py
@@ -24,8 +24,8 @@ from . import cpuv_common
__author__ = "Nutti <nutti.metro at gmail.com>"
__status__ = "production"
-__version__ = "3.0"
-__date__ = "15 Jun 2015"
+__version__ = "3.2"
+__date__ = "20 Jun 2015"
# flip/rotate
@@ -34,7 +34,7 @@ class CPUVFlipRotate(bpy.types.Operator):
bl_idname = "uv.flip_rotate"
bl_label = "Flip/Rotate UV"
- bl_description = "Flip/Rotate UV."
+ bl_description = "Flip/Rotate UV"
bl_options = {'REGISTER', 'UNDO'}
flip = BoolProperty(
diff --git a/uv_copy_and_paste_uv/cpuv_menu.py b/uv_copy_and_paste_uv/cpuv_menu.py
index ce0df03..90776ce 100644
--- a/uv_copy_and_paste_uv/cpuv_menu.py
+++ b/uv_copy_and_paste_uv/cpuv_menu.py
@@ -22,8 +22,8 @@ import bpy
__author__ = "Nutti <nutti.metro at gmail.com>"
__status__ = "production"
-__version__ = "3.0"
-__date__ = "15 Jun 2015"
+__version__ = "3.2"
+__date__ = "20 Jun 2015"
from . import cpuv_default_operation
from . import cpuv_selseq_operation
diff --git a/uv_copy_and_paste_uv/cpuv_properties.py b/uv_copy_and_paste_uv/cpuv_properties.py
index 8551f7d..0c0e600 100644
--- a/uv_copy_and_paste_uv/cpuv_properties.py
+++ b/uv_copy_and_paste_uv/cpuv_properties.py
@@ -21,10 +21,12 @@
__author__ = "Nutti <nutti.metro at gmail.com>"
__status__ = "production"
-__version__ = "3.0"
-__date__ = "15 Jun 2015"
+__version__ = "3.2"
+__date__ = "20 Jun 2015"
+DEBUG = False
+
# Properties used in this add-on.
class CPUVProperties():
default = None
@@ -58,9 +60,7 @@ class CPUVUVMapOpsProps():
class CPUVTransUVOpsProps():
- src_uv_map = None
- src_obj_name = None
- src_faces = None
+ topology_copied = []
def init_properties(props):
diff --git a/uv_copy_and_paste_uv/cpuv_selseq_operation.py b/uv_copy_and_paste_uv/cpuv_selseq_operation.py
index a3fe3e3..e2808c0 100644
--- a/uv_copy_and_paste_uv/cpuv_selseq_operation.py
+++ b/uv_copy_and_paste_uv/cpuv_selseq_operation.py
@@ -24,8 +24,8 @@ from . import cpuv_common
__author__ = "Nutti <nutti.metro at gmail.com>"
__status__ = "production"
-__version__ = "3.0"
-__date__ = "15 Jun 2015"
+__version__ = "3.2"
+__date__ = "20 Jun 2015"
# copy UV (by selection sequence)
@@ -34,7 +34,7 @@ class CPUVSelSeqCopyUV(bpy.types.Operator):
bl_idname = "uv.cpuv_selseq_copy_uv"
bl_label = "Copy UV (Selection Sequence)"
- bl_description = "Copy UV data by selection sequence."
+ bl_description = "Copy UV data by selection sequence"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
@@ -65,7 +65,7 @@ class CPUVSelSeqPasteUV(bpy.types.Operator):
bl_idname = "uv.cpuv_selseq_paste_uv"
bl_label = "Paste UV (Selection Sequence)"
- bl_description = "Paste UV data by selection sequence."
+ bl_description = "Paste UV data by selection sequence"
bl_options = {'REGISTER', 'UNDO'}
flip_copied_uv = BoolProperty(
diff --git a/uv_copy_and_paste_uv/cpuv_transfer_uv_operation.py b/uv_copy_and_paste_uv/cpuv_transfer_uv_operation.py
index a536970..4d3a3ed 100644
--- a/uv_copy_and_paste_uv/cpuv_transfer_uv_operation.py
+++ b/uv_copy_and_paste_uv/cpuv_transfer_uv_operation.py
@@ -19,59 +19,15 @@
# ##### END GPL LICENSE BLOCK #####
import bpy
-from bpy.props import FloatProperty, EnumProperty
-import copy
-import math
-import mathutils
-
+import bmesh
+from collections import OrderedDict
+from . import cpuv_properties
from . import cpuv_common
-__author__ = "Nutti <nutti.metro at gmail.com>"
+__author__ = "Nutti <nutti.metro at gmail.com>, Mifth"
__status__ = "production"
-__version__ = "3.0"
-__date__ = "15 Jun 2015"
-
-
-def is_matched(diff, precise):
- r1 = math.fabs(diff.x) < precise
- r2 = math.fabs(diff.y) < precise
- r3 = math.fabs(diff.z) < precise
- return r1 and r2 and r3
-
-
-# filter faces
-def filter_faces(src, dest, precise, strategy):
- strategy_fn = None
-
- if strategy == "NONE":
- strategy_fn = (lambda s, d, precise:
- True)
- elif strategy == "CENTER":
- strategy_fn = (lambda s, d, precise:
- is_matched(s.center - d.center, precise))
- elif strategy == "NORMAL":
- strategy_fn = (lambda s, d, precise:
- is_matched(s.normal - d.normal, precise))
- elif strategy == "INDEX":
- strategy_fn = (lambda s, d, precise:
- s.indices == d.indices)
-
- return zip(*[(s, d)
- for s, d in zip(src, dest)
- if len(s.indices) == len(d.indices) and
- strategy_fn(s, d, precise)
- ])
-
-
-def get_strategy(scene, context):
- items = []
-
- items.append(("NONE", "None", "No strategy."))
- items.append(("NORMAL", "Normal", "Normal."))
- items.append(("CENTER", "Center", "Center of face."))
- items.append(("INDEX", "Index", "Vertex Index."))
-
- return items
+__version__ = "3.2"
+__date__ = "20 Jun 2015"
# transfer UV (copy)
@@ -80,35 +36,44 @@ class CPUVTransferUVCopy(bpy.types.Operator):
bl_idname = "uv.transfer_uv_copy"
bl_label = "Transfer UV Copy"
- bl_description = "Transfer UV Copy."
+ bl_description = "Transfer UV Copy"
bl_options = {'REGISTER', 'UNDO'}
- src_obj_name = None
- src_face_indices = None
-
def execute(self, context):
props = context.scene.cpuv_props.transuv
- self.report({'INFO'}, "Transfer UV copy.")
- mem = cpuv_common.View3DModeMemory(context)
- cpuv_common.update_mesh()
- # get active object name
- props.src_obj_name = context.active_object.name
- # prepare for coping
- ret, src_obj = cpuv_common.prep_copy(context, self)
- if ret != 0:
+ active_obj = context.scene.objects.active
+ bm = bmesh.from_edit_mesh(active_obj.data)
+
+ if not bm.loops.layers.uv:
+ self.report({'WARNING'}, "No UV Map!!")
return {'CANCELLED'}
- # copy
- src_sel_face_info = cpuv_common.get_selected_faces_by_sel_seq(
- src_obj)
- props.src_faces = cpuv_common.get_selected_face_indices(
- context, src_obj)
- ret, props.src_uv_map = cpuv_common.copy_opt(
- self, "", src_obj, src_sel_face_info)
- if ret != 0:
+
+ uv_layer = bm.loops.layers.uv.verify()
+ props.topology_copied.clear()
+
+ # get selected faces
+ active_face = bm.faces.active
+ sel_faces = [face for face in bm.faces if face.select]
+ if len(sel_faces) != 2 or not active_face or active_face not in sel_faces:
+ self.report({'WARNING'}, "Two faces should be selected and active!!")
return {'CANCELLED'}
- # finish coping
- cpuv_common.fini_copy()
- # revert to original mode
+
+ # parse all faces according to selection
+ all_sorted_faces = main_parse(self, active_obj, bm, uv_layer, sel_faces, active_face)
+
+ if all_sorted_faces:
+ for face_data in all_sorted_faces.values():
+ uv_loops = face_data[2]
+ uvs = []
+ pin_uvs = []
+ for loop in uv_loops:
+ uvs.append(loop.uv.copy())
+ pin_uvs.append(loop.pin_uv)
+
+ props.topology_copied.append([uvs, pin_uvs])
+
+ bmesh.update_edit_mesh(active_obj.data)
+
return {'FINISHED'}
@@ -118,132 +83,228 @@ class CPUVTransferUVPaste(bpy.types.Operator):
bl_idname = "uv.transfer_uv_paste"
bl_label = "Transfer UV Paste"
- bl_description = "Transfer UV Paste."
+ bl_description = "Transfer UV Paste"
bl_options = {'REGISTER', 'UNDO'}
- flip_copied_uv = False
- rotate_copied_uv = 0
-
- precise = FloatProperty(
- default=0.1,
- name="Precise",
- min=0.000001,
- max=
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list