Blender python trying to scale the uv I am trying to enlarge the uv map  using python scripting so more square in my texture. Not sure what is wrong.
bpy.ops.object.select_all(action='DESELECT')
XYZcoord = (0, 0 ,0)
ob = bpy.ops.mesh.primitive_plane_add(location=XYZcoord)
bpy.ops.transform.resize(value=( 20, 20, 20))
bpy.ops.object.mode_set(mode=&quot;EDIT&quot;)
bpy.ops.mesh.subdivide(number_cuts=10)
bpy.ops.uv.smart_project()
bpy.ops.object.mode_set(mode=&quot;OBJECT&quot;)
material_image = bpy.data.materials.new(name= &quot;Basic_Texture&quot;)
material_image.use_nodes = True
principled_node = material_image.node_tree.nodes.get('Principled BSDF')
principled_node.inputs[7].default_value = 0.08
texImage = material_image.node_tree.nodes.new('ShaderNodeTexImage')
texImage.location = (-300, 400)
texImage.image = bpy.data.images.load(&quot;H:\\blender__texture_maps_ao_normal_height_etc\\Wooden_planks_04_2K_Base_Color.png&quot;)
material_image.node_tree.links.new(principled_node.inputs['Base Color'], texImage.outputs['Color'])
texImage_rough = material_image.node_tree.nodes.new('ShaderNodeTexImage')
texImage_rough.location = (-300, 0)
texImage_rough.image = bpy.data.images.load(&quot;H:\\blender__texture_maps_ao_normal_height_etc\\Wooden_planks_04_2K_Roughness.png&quot;)
texImage_rough.image.colorspace_settings.name = 'Non-Color'
material_image.node_tree.links.new(principled_node.inputs['Roughness'], texImage_rough.outputs['Color'])
bpy.ops.object.shade_smooth()
bpy.context.object.active_material = material_image


bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.uv.select_all(action='SELECT')
bpy.ops.mesh.select_mode(type='EDGE')
bpy.context.area.ui_type = 'UV'
bpy.ops.transform.resize(value=(2, 2, 2), orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', mirror=True, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False)
bpy.ops.object.mode_set(mode='OBJECT')
print(bpy.context.active_object)
Maybe u forget to add 'R' before the file path?
bpy.data.images.load(R&quot;H:\blender__texture_maps_ao_normal_height_etc\Wooden_planks_04_2K_Base_Color.png&quot;)
It should raise an error in python but my blender doesn't show any error message. Everything works fine in my blender.
Edit: You can use the following code to scale your uv instead of using bpy.ops.transform.resize
See more information here
me = bpy.context.object.data
uv_layer = me.uv_layers.active.data

scale_factor = 2
for poly in me.polygons:
    for loop_index in range(poly.loop_start, poly.loop_start + poly.loop_total):
        # rearrange uv coordinate from 0~1 to -1~1 and scale it.
        uv_layer[loop_index].uv.x = (uv_layer[loop_index].uv.x - 0.5) * 2 * scale_factor / 2 + 0.5
        uv_layer[loop_index].uv.y = (uv_layer[loop_index].uv.y - 0.5) * 2 * scale_factor / 2 + 0.5