Python Templates: fix operator_mesh_uv template
This commit is contained in:
@@ -9,13 +9,12 @@ def main(context):
|
|||||||
|
|
||||||
uv_layer = bm.loops.layers.uv.verify()
|
uv_layer = bm.loops.layers.uv.verify()
|
||||||
|
|
||||||
# adjust UVs
|
# adjust uv coordinates
|
||||||
for f in bm.faces:
|
for face in bm.faces:
|
||||||
for l in f.loops:
|
for loop in face.loops:
|
||||||
luv = l[uv_layer]
|
loop_uv = loop[uv_layer]
|
||||||
if luv.select:
|
# use xy position of the vertex as a uv coordinate
|
||||||
# apply the location of the vertex as a UV
|
loop_uv.uv = loop.vert.co.xy
|
||||||
luv.uv = l.vert.co.xy
|
|
||||||
|
|
||||||
bmesh.update_edit_mesh(me)
|
bmesh.update_edit_mesh(me)
|
||||||
|
|
||||||
@@ -27,7 +26,8 @@ class UvOperator(bpy.types.Operator):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
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):
|
def execute(self, context):
|
||||||
main(context)
|
main(context)
|
||||||
|
Reference in New Issue
Block a user