def create(name, family):
"""Create new instance
Associate nodes with a name and family. These nodes are later
validated, according to their `family`, and integrated into the
shared environment, relative their `name`.
Data relative each family, along with default data, are imprinted
into the resulting objectSet. This data is later used by extractors
and finally asset browsers to help identify the origin of the asset.
Arguments:
name (str): Name of instance
family (str): Name of family
Raises:
NameError on `name` already exists
KeyError on invalid dynamic property
RuntimeError on host error
"""
for item in api.registered_families():
if item["name"] == family:
break
assert item is not None, "{0} is not a valid family".format(family)
data = api.registered_data() + item.get("data", [])
# Convert to dictionary
data = dict((i["key"], i["value"]) for i in data)
instance = "%s_SEL" % name
if cmds.objExists(instance):
raise NameError("\"%s\" already exists." % instance)
instance = cmds.sets(name=instance)
# Resolve template
for key, value in data.items():
try:
data[key] = value.format(
name=name,
family=family
)
except KeyError as e:
raise KeyError("Invalid dynamic property: %s" % e)
lib.imprint(instance, data)
cmds.select(instance, noExpand=True)
return instance
评论列表
文章目录