BallanceBlenderHelper/ballance_blender_plugin/no_uv_checker.py
yyc12345 08eb6dcff9 [add] add ui and fix naming problem
- renaming all classes
- add conflict option for importing bm. no real code
- add shift + a menu, still no real code
2020-09-02 23:04:21 +08:00

46 lines
1.4 KiB
Python

import bpy,bmesh
from . import utils
class BALLANCE_OT_no_uv_checker(bpy.types.Operator):
"""Check whether the currently selected object has UV"""
bl_idname = "ballance.no_uv_checker"
bl_label = "Check UV"
bl_options = {'UNDO'}
@classmethod
def poll(self, context):
return check_valid_target()
def execute(self, context):
check_target()
return {'FINISHED'}
# ====================== method
def check_valid_target():
return (len(bpy.context.selected_objects) > 0)
def check_target():
noUVObject = []
invalidObjectCount = 0
for obj in bpy.context.selected_objects:
if obj.type != 'MESH':
invalidObjectCount+=1
continue
if obj.mode != 'OBJECT':
invalidObjectCount+=1
continue
if obj.data.uv_layers.active is None:
noUVObject.append(obj.name)
result = ("All objects: {}, Skipped: {}, No UV Count: {}. Following object don't have UV: ".format(len(bpy.context.selected_objects), invalidObjectCount, len(noUVObject)) +
", ".join(noUVObject[:4]) +
(". Too much objects don't have UV. Please open terminal to browse them." if len(noUVObject) > 4 else ""))
if len(noUVObject) > 4:
print("Following object don't have UV:")
for item in noUVObject:
print(item)
utils.ShowMessageBox(result, "Check result", 'INFO')