forked from franMarz/TexTools-Blender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
op_uv_size_get.py
44 lines (31 loc) · 1.02 KB
/
op_uv_size_get.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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):
bl_idname = "uv.textools_uv_size_get"
bl_label = "Get Size"
bl_description = "Get selected object's texture size"
@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
if bpy.context.active_object.type != 'MESH':
return False
return True
def execute(self, context):
get_size(self, context)
return {'FINISHED'}
def get_size(self, context):
image = utilities_texel.get_object_texture_image (bpy.context.active_object)
if not image:
self.report({'ERROR_INVALID_INPUT'}, "No Texture found on selected object" )
return
bpy.context.scene.texToolsSettings.size[0] = image.size[0]
bpy.context.scene.texToolsSettings.size[1] = image.size[1]
bpy.utils.register_class(op)