def process(self, context):
from maya import cmds
for objset in cmds.ls("*.id",
long=True, # Produce full names
type="objectSet", # Only consider objectSets
recursive=True, # Include namespace
objectsOnly=True): # Return objectSet, rather
# than its members
is_empty = cmds.sets(objset, query=True) is None
if is_empty:
self.log.info("%s skipped, it was empty." % objset)
continue
if not cmds.objExists(objset + ".id"):
continue
if cmds.getAttr(objset + ".id") not in (
"pyblish.avalon.instance",
# Backwards compatibility
"pyblish.mindbender.instance"):
continue
# The developer is responsible for specifying
# the family of each instance.
assert cmds.objExists(objset + ".family"), (
"\"%s\" was missing a family" % objset)
data = dict()
# Apply each user defined attribute as data
for attr in cmds.listAttr(objset, userDefined=True) or list():
try:
value = cmds.getAttr(objset + "." + attr)
except Exception:
# Some attributes cannot be read directly,
# such as mesh and color attributes. These
# are considered non-essential to this
# particular publishing pipeline.
value = None
data[attr] = value
name = cmds.ls(objset, long=False)[0] # Use short name
instance = context.create_instance(data.get("name", name))
instance[:] = cmds.sets(objset, query=True) or list()
instance.data.update(data)
# Produce diagnostic message for any graphical
# user interface interested in visualising it.
self.log.info("Found: \"%s\" " % instance.data["name"])
评论列表
文章目录