custom_shelf/devshelf/dev/rigs/check_proxys.py

60 lines
2.2 KiB
Python
Raw Normal View History

2022-03-04 12:28:53 +01:00
info = {
'icon' : 'ARMATURE_DATA',
'description' : 'run some check on proxys and armautre and print in console',
}
# coding: utf-8
import bpy
import os
from os import listdir
from os.path import join, dirname, basename, exists, isfile, isdir, splitext
import re, fnmatch, glob
from mathutils import Vector, Matrix
from math import radians, degrees
C = bpy.context
D = bpy.data
scene = bpy.context.scene
print('\nCollection instance check -- ')
problems = []
for o in bpy.context.scene.objects:
if o.instance_collection:
for instob in o.instance_collection.objects:
badname = withproxy = withcolproxy = alert = ''
if instob.type == 'ARMATURE':
mess = f'{o.name} -> rig: {instob.name}'
arm = instob.data
# print("arm", arm.name)#Dbg
if instob.name != arm.name:
badname = 1
mess += f' != arm data: {arm.name}'
rigname = arm.name.replace('_rig','_proxy') if 'rig' in arm.name else arm.name + '_proxy'
proxy = bpy.context.scene.objects.get(rigname)
if proxy:
withproxy = 1
mess += ' ->> Proxy in scene'
if not proxy:
collec_proxy = instob.name.replace('_rig','_proxy') if 'rig' in instob.name else instob.name + '_proxy'
proxy = bpy.context.scene.objects.get(collec_proxy)
if proxy :
withcolproxy = 1
mess += ' ->> Proxy from colname in scene'
if proxy and proxy.animation_data and proxy.animation_data.action and len(proxy.animation_data.action.fcurves) > 0:
mess += ' (animated)'
if badname and withcolproxy:
alert = '!!!'
elif badname and withproxy:
alert = '!!'
elif badname:
alert = '!'
mess = f'{alert} {mess}'
if badname or withproxy or withcolproxy:
problems.append(mess)
print(mess)
print('Done')