I want to create a script that checks if the selected mesh has an UV Channel, if not it does a Smart UV Project.
1 Answer
This will do the trick:
import bpy
# Check if active object has any UV layers
if not len( bpy.context.object.data.uv_layers ):
bpy.ops.uv.smart_project() # Perform smart UV projection
-
$\begingroup$ Thank you! Also we don't need to enter in edit mode to do a smart project with scripts. $\endgroup$ Jul 22, 2017 at 13:04
-
$\begingroup$ Well I'll be, you're right - I'll fix the code above. $\endgroup$– TLouskyJul 22, 2017 at 13:06