I want to be able to use Smart UV project on thousands of separate objects in a scene at once. I'm wanting the result to be as if I'd applied the Smart UV project to each individual object one at a time. Using A to select all and SPACE then Smart UV Project just seems to create a problem in sense that when I import even a single object into Unreal Engine it behaves like it has an enormous footprint bigger than my terrain map, even though the object itself does not and is small. Any advice or suggestions would be most welcome.

up vote 4 down vote accepted

Scripting with Python

As you mentioned, Smart Unwrap in object mode takes all the objects as a whole. It's more useful to create a texture atlas, rather than individual UV maps.

Like in most scenarios where a tedius task must be done several times, you can try to automate the process with python code. You can write a script that iterates through all the selected object of the scene, enter edit mode for each object, select all the elements of the object an run the smart_project() function.

Here's what a possible script could look like:

import bpy

if bpy.context.selected_objects != []:
    for obj in bpy.context.selected_objects: #loop through all the selected objects
        if obj.type == 'MESH':
            bpy.context.scene.objects.active = obj
            bpy.ops.object.editmode_toggle() #entering edit mode
            bpy.ops.mesh.select_all(action='SELECT') #select all objects elements
            bpy.ops.uv.smart_project() #the actual unwrapping operation
            bpy.ops.object.editmode_toggle() #exiting edit mode

enter image description here

  • 1
    Thanks Carlo, you are an absolute superstar for putting me on the right track with this. I'd no idea you could use python for automation of tasks as I'm new to Blender. Using a "for each" to select each object in a loop and apply the UV Smart Project seems to work perfectly. :-) – James Clow Mar 16 at 0:12

I took the origin code by Carlo and have created an small AddOn that can be installed in Blender.

This is my very first Blender Add-On and I'm not a good coder... So it’s nothing special, but helped me a lot.

What it does:

  • It executes the Smart UV project function to all selected mesh objects in the scene.
  • Correct Aspect ratio is always ON, Stretch to UV Bounds is always OFF.
  • After the regular installation in the preferences you can activate the Add-On by pressing the spacebar and type „Smart“ in. Then „Smart UV project selected objects“ appear and you can execute it.

The quick script helped me a lot here. I hope it's something for you too.

Here is the link for the download:

http://www.christoph-werner.de/2018/08/03/smart-uv-project-all-selected-objects-blender-add-on/

Best wishes

Chris

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.