Get the latest Blender, older versions, or experimental builds.
Stay up-to-date with the new features in the latest Blender releases.
Access production assets and knowledge from the open movies.
Documentation on the usage and features in Blender.
Latest development updates, by Blender developers.
Guidelines, release notes and development docs.
A platform to collect and share results of the Blender Benchmark.
The yearly event that brings the community together.
Support core development with a monthly contribution.
Perform a single donation with more payment options available.
import bpy
def main(context):
obj = context.active_object
mesh = obj.data
is_editmode = (obj.mode == 'EDIT')
if is_editmode:
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
if not mesh.active_uv_texture:
bpy.ops.mesh.uv_texture_add()
# adjust UVs
for i, uv in enumerate(mesh.active_uv_texture.data):
uvs = uv.uv1, uv.uv2, uv.uv3, uv.uv4
for j, v_idx in enumerate(mesh.faces[i].verts):
if uv.select_uv[j]:
# apply the location of the vertex as a UV
uvs[j][:] = mesh.verts[v_idx].co.xy
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
class UvOperator(bpy.types.Operator):
''''''
bl_idname = "uv.simple_operator"
bl_label = "Simple UV Operator"
def poll(self, context):
return (obj and obj.type == 'MESH')
def execute(self, context):
main(context)
return {'FINISHED'}
if __name__ == "__main__":
bpy.ops.uv.simple_operator()