1
0
mirror of https://github.com/drewcassidy/TexTools-Blender synced 2024-06-11 00:26:53 +00:00
Blender-TexTools/op_uv_size_get.py

44 lines
1.1 KiB
Python
Raw Normal View History

2019-06-08 23:42:50 +00:00
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):
2019-12-18 20:53:16 +00:00
bl_idname = "uv.textools_uv_size_get"
bl_label = "Get Size"
bl_description = "Get selected object's texture size"
2019-06-08 23:42:50 +00:00
2019-12-18 20:53:16 +00:00
@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
2019-06-08 23:42:50 +00:00
2019-12-18 20:53:16 +00:00
if bpy.context.active_object.type != 'MESH':
return False
2019-06-08 23:42:50 +00:00
2019-12-18 20:53:16 +00:00
return True
def execute(self, context):
get_size(self, context)
return {'FINISHED'}
2019-06-08 23:42:50 +00:00
def get_size(self, context):
2019-12-18 20:53:16 +00:00
image = utilities_texel.get_object_texture_image (bpy.context.active_object)
2019-06-08 23:42:50 +00:00
2019-12-18 20:53:16 +00:00
if not image:
self.report({'ERROR_INVALID_INPUT'}, "No Texture found on selected object" )
return
2019-06-08 23:42:50 +00:00
2019-12-18 20:53:16 +00:00
bpy.context.scene.texToolsSettings.size[0] = image.size[0]
bpy.context.scene.texToolsSettings.size[1] = image.size[1]
2019-06-08 23:42:50 +00:00
bpy.utils.register_class(op)