create get_custom_namespace function to control the position of the unique index

This commit is contained in:
Thomas Fricard 2023-04-07 14:34:22 +02:00
parent c38ee97246
commit 163e01542c

View file

@ -1,4 +1,5 @@
import os
import re
from maya import cmds
@ -83,6 +84,25 @@ def get_reference_node_parents(ref):
return parents
def get_custom_namespace(custom_namespace):
split = re.split("([#]+)", custom_namespace, 1)
if len(split) == 3:
base, padding, suffix = split
padding = "%0{}d".format(len(padding))
else:
base = split[0]
padding = "%02d"
suffix = ""
return lib.unique_namespace(
base,
format=padding,
prefix="_" if not base or base[0].isdigit() else "",
suffix=suffix
)
class Creator(LegacyCreator):
defaults = ['Main']
@ -177,11 +197,7 @@ class ReferenceLoader(Loader):
count = options.get("count") or 1
for c in range(0, count):
namespace = lib.unique_namespace(
custom_namespace,
prefix="_" if custom_namespace[0].isdigit() else "",
suffix=""
)
namespace = get_custom_namespace(custom_namespace)
group_name = "{}:{}".format(
namespace,
custom_group_name