You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Blender-TexTools/op_uv_size_get.py

44 lines
1.1 KiB
Python

import bpy
import bmesh
import operator
from mathutils import Vector
from collections import defaultdict
from math import pi
from . import utilities_texel
class op(bpy.types.Operator):
4 years ago
bl_idname = "uv.textools_uv_size_get"
bl_label = "Get Size"
bl_description = "Get selected object's texture size"
4 years ago
@classmethod
def poll(cls, context):
if not bpy.context.active_object:
return False
if bpy.context.active_object not in bpy.context.selected_objects:
return False
4 years ago
if bpy.context.active_object.type != 'MESH':
return False
4 years ago
return True
def execute(self, context):
get_size(self, context)
return {'FINISHED'}
def get_size(self, context):
4 years ago
image = utilities_texel.get_object_texture_image (bpy.context.active_object)
4 years ago
if not image:
self.report({'ERROR_INVALID_INPUT'}, "No Texture found on selected object" )
return
4 years ago
bpy.context.scene.texToolsSettings.size[0] = image.size[0]
bpy.context.scene.texToolsSettings.size[1] = image.size[1]
bpy.utils.register_class(op)