[Bf-blender-cvs] [54021da58bb] master: Python Templates: fix operator_mesh_uv template

Jacques Lucke noreply at git.blender.org
Thu Jun 6 14:36:26 CEST 2019


Commit: 54021da58bb0a593cbdfa38317d2d8a16fa1780c
Author: Jacques Lucke
Date:   Thu Jun 6 14:36:08 2019 +0200
Branches: master
https://developer.blender.org/rB54021da58bb0a593cbdfa38317d2d8a16fa1780c

Python Templates: fix operator_mesh_uv template

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

M	release/scripts/templates_py/operator_mesh_uv.py

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

diff --git a/release/scripts/templates_py/operator_mesh_uv.py b/release/scripts/templates_py/operator_mesh_uv.py
index 4d25b7af37e..bf893480f2f 100644
--- a/release/scripts/templates_py/operator_mesh_uv.py
+++ b/release/scripts/templates_py/operator_mesh_uv.py
@@ -9,13 +9,12 @@ def main(context):
 
     uv_layer = bm.loops.layers.uv.verify()
 
-    # adjust UVs
-    for f in bm.faces:
-        for l in f.loops:
-            luv = l[uv_layer]
-            if luv.select:
-                # apply the location of the vertex as a UV
-                luv.uv = l.vert.co.xy
+    # adjust uv coordinates
+    for face in bm.faces:
+        for loop in face.loops:
+            loop_uv = loop[uv_layer]
+            # use xy position of the vertex as a uv coordinate
+            loop_uv.uv = loop.vert.co.xy
 
     bmesh.update_edit_mesh(me)
 
@@ -27,7 +26,8 @@ class UvOperator(bpy.types.Operator):
 
     @classmethod
     def poll(cls, context):
-        return (context.mode == 'EDIT_MESH')
+        obj = context.active_object
+        return obj and obj.type == 'MESH' and obj.mode == 'EDIT'
 
     def execute(self, context):
         main(context)



More information about the Bf-blender-cvs mailing list