Last active
October 6, 2020 08:27
-
-
Save sambler/d8384a36ef07d33010574d3a104b1e42 to your computer and use it in GitHub Desktop.
uvunwrap a blender object using a script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# save this as uvproject.py and use the following command | |
# blender -b test.blend -P uvproject.py | |
import bpy | |
# Deselect all | |
bpy.ops.object.select_all(action='DESELECT') | |
for obj in bpy.context.scene.objects: | |
if obj.type == 'MESH': | |
obj.select_set(state=True) | |
bpy.context.view_layer.objects.active = obj | |
bpy.ops.object.mode_set(mode='EDIT') | |
bpy.ops.mesh.select_all(action='SELECT') | |
if len(obj.data.uv_layers) == 0: | |
obj.data.uv_layers.new() | |
bpy.ops.uv.smart_project() | |
bpy.ops.object.mode_set(mode='OBJECT') | |
bpy.ops.wm.save_mainfile() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment