diff options
Diffstat (limited to 'release/scripts/templates/operator_uv.py')
-rw-r--r-- | release/scripts/templates/operator_uv.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/release/scripts/templates/operator_uv.py b/release/scripts/templates/operator_uv.py index 36d8333d49d..305496e31ce 100644 --- a/release/scripts/templates/operator_uv.py +++ b/release/scripts/templates/operator_uv.py @@ -1,3 +1,4 @@ +import bpy def main(context): obj = context.active_object @@ -8,27 +9,29 @@ def main(context): bpy.ops.object.mode_set(mode='OBJECT', toggle=False) - if not mesh.active_uv_texture: - bpy.ops.mesh.uv_texture_add() + if not mesh.uv_textures: + uvtex = bpy.ops.mesh.uv_texture_add() # adjust UVs - for i, uv in enumerate(mesh.active_uv_texture.data): + for i, uv in enumerate(uvtex.data): uvs = uv.uv1, uv.uv2, uv.uv3, uv.uv4 - for j, v_idx in enumerate(mesh.faces[i].verts): - if uv.uv_selected[j]: + for j, v_idx in enumerate(mesh.faces[i].vertices): + if uv.select_uv[j]: # apply the location of the vertex as a UV - uvs[j][:] = mesh.verts[v_idx].co.xy + uvs[j][:] = mesh.vertices[v_idx].co.xy if is_editmode: bpy.ops.object.mode_set(mode='EDIT', toggle=False) + class UvOperator(bpy.types.Operator): - '''''' + '''UV Operator description''' bl_idname = "uv.simple_operator" bl_label = "Simple UV Operator" - def poll(self, context): + @classmethod + def poll(cls, context): obj = context.active_object return (obj and obj.type == 'MESH') @@ -36,7 +39,6 @@ class UvOperator(bpy.types.Operator): main(context) return {'FINISHED'} -bpy.types.register(UvOperator) if __name__ == "__main__": bpy.ops.uv.simple_operator() |