From 54021da58bb0a593cbdfa38317d2d8a16fa1780c Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 6 Jun 2019 14:36:08 +0200 Subject: Python Templates: fix operator_mesh_uv template --- release/scripts/templates_py/operator_mesh_uv.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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) -- cgit v1.2.3