[Bf-blender-cvs] [b8710e1] master: Fix UV layer bug in object_utils.object_data_add()

Campbell Barton noreply at git.blender.org
Fri Nov 18 20:46:39 CET 2016


Commit: b8710e1468a3ce523c35260e47332393e2b967a3
Author: Campbell Barton
Date:   Sat Nov 19 06:57:55 2016 +1100
Branches: master
https://developer.blender.org/rBb8710e1468a3ce523c35260e47332393e2b967a3

Fix UV layer bug in object_utils.object_data_add()

Adding a torus in edit-mode, with 'Generate UVs'
for example would either create another UV layer with the default name or
switch to the default UV layer name if it exists.

Now use the existing UV layer if present.

===================================================================

M	release/scripts/modules/bpy_extras/object_utils.py

===================================================================

diff --git a/release/scripts/modules/bpy_extras/object_utils.py b/release/scripts/modules/bpy_extras/object_utils.py
index 88cd739..c48f03c 100644
--- a/release/scripts/modules/bpy_extras/object_utils.py
+++ b/release/scripts/modules/bpy_extras/object_utils.py
@@ -189,6 +189,14 @@ def object_data_add(context, obdata, operator=None, use_active_layer=True, name=
         scene.update()  # apply location
         # scene.objects.active = obj_new
 
+        # Match up UV layers, this is needed so adding an object with UV's
+        # doesn't create new layers when there happens to be a naming mis-match.
+        uv_new = obdata.uv_layers.active
+        if uv_new is not None:
+            uv_act = obj_act.data.uv_layers.active
+            if uv_act is not None:
+                uv_new.name = uv_act.name
+
         bpy.ops.object.join()  # join into the active.
         if obdata:
             bpy.data.meshes.remove(obdata)




More information about the Bf-blender-cvs mailing list