Skip to content
Snippets Groups Projects
Commit e501ab49 authored by Nathan Vegdahl's avatar Nathan Vegdahl
Browse files

Rigify patch from Campbell, to clean up some of the code.

parent 471be493
No related branches found
No related tags found
No related merge requests found
...@@ -27,45 +27,45 @@ bl_addon_info = { ...@@ -27,45 +27,45 @@ bl_addon_info = {
"tracker_url": "", "tracker_url": "",
"category": "Rigging"} "category": "Rigging"}
import bpy if "bpy" in locals():
import bpy_types
import os
from imp import reload
try:
reload(generate) reload(generate)
reload(ui) reload(ui)
reload(utils) reload(utils)
reload(metarig_menu) reload(metarig_menu)
except NameError: else:
from rigify import generate, ui, utils, metarig_menu from rigify import generate, ui, utils, metarig_menu
import bpy
import bpy_types
import os
def get_rig_list(path): def get_rig_list(path):
""" Recursively searches for rig types, and returns a list. """ Recursively searches for rig types, and returns a list.
""" """
rigs = [] rigs = []
files = os.listdir(os.path.dirname(__file__) + "/" + utils.RIG_DIR + "/" + path) MODULE_DIR = os.path.dirname(__file__)
files = sorted(files) RIG_DIR_ABS = os.path.join(MODULE_DIR, utils.RIG_DIR)
SEARCH_DIR_ABS = os.path.join(RIG_DIR_ABS, path)
path_strip = path.strip(os.sep)
files = os.listdir(SEARCH_DIR_ABS)
files.sort()
for f in files: for f in files:
if not f.startswith("_"): if not f.startswith("_") and not f.startswith("."):
if os.path.isdir(os.path.dirname(__file__) + "/" + utils.RIG_DIR + "/" + path + f): f_abs = os.path.join(SEARCH_DIR_ABS, f)
if os.path.isdir(f_abs):
# Check directories # Check directories
try: try:
rig = utils.get_rig_type((path + f).replace("/", ".")) rig = utils.get_rig_type(os.path.join(path_strip, f).replace(os.sep, "."))
except ImportError as e: except ImportError as e:
print("Rigify: " + str(e)) print("Rigify: " + str(e))
else: else:
# Check if it's a rig itself # Check if it's a rig itself
try: if not hasattr(rig, "Rig"):
rig.Rig
except AttributeError:
# Check for sub-rigs # Check for sub-rigs
ls = get_rig_list(path + f + "/") ls = get_rig_list(os.path.join(path, f, "")) # "" adds a final slash
for l in ls: rigs.extend(["%s.%s" % (f, l) for l in ls])
rigs += [f + '.' + l]
else: else:
rigs += [f] rigs += [f]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment