0
$\begingroup$

I need to scale UV islands by their individual origins using Python. I've tried for a long time but I can't get it to work in a non-interactive environment. Any help would be greatly appreciated! Thank you so much in advance!

import bpy
bpy.context.area.ui_type = 'UV'
bpy.context.space_data.pivot_point = 'INDIVIDUAL_ORIGINS'
bpy.ops.transform.resize(value=(scale_length, scale_width, 1)

I've also tried using 'World Scale UV' from the MagicUV addon. The problem with this is that it only allows for uniform scaling. So different scale on different axis won't work.

Background info: This will be used for custom size and shapes of nameplates for a three.js configurator. There are about 10k objects of different sizes and shapes that need a 'World scaled' UV to make it look more realistic.

$\endgroup$

1 Answer 1

0
$\begingroup$

you must select all uv island before scale it:

import bpy
scale_length= 0.5
scale_width = 0.7

original_type = bpy.context.area.ui_type
bpy.context.area.ui_type = 'UV'
bpy.ops.uv.select_all(action='SELECT')
bpy.context.space_data.pivot_point = 'INDIVIDUAL_ORIGINS'
bpy.ops.transform.resize(value=(scale_length, scale_width, 1))


bpy.context.area.ui_type = original_type
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .