Skip to content

Instantly share code, notes, and snippets.

@thendrix
Created June 9, 2018 03:26
Show Gist options
  • Save thendrix/a1db221bc652d9bc2ab02769de236104 to your computer and use it in GitHub Desktop.
Save thendrix/a1db221bc652d9bc2ab02769de236104 to your computer and use it in GitHub Desktop.
# @file This blender script finds all meshes without UVs and unwraps them.
# @author Terry Hendrix II github/thendrix
import bpy
# Unselect objects
for obj in bpy.context.selected_objects:
obj.select = False
# Find and process meshes without UVs
for obj in bpy.context.scene.objects:
if not obj.type == 'MESH' or obj.data.uv_layers:
print("Skipping: ", obj.type, obj.name)
else:
print("Unwrapping:", obj.name)
# Select mesh, select all mesh faces, and unwrap
obj.select = True
bpy.ops.uv.smart_project()
# Unselect obj to avoid grouping selections
obj.select = False
# Select all with UVs
for obj in bpy.context.scene.objects:
if obj.type == 'MESH' and obj.data.uv_layers:
obj.select = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment