When creating a workfile from the template everything works, but on the publish step i get an error. Looking in the outliner it seems that the placeholder locator is still in the look set, which is why the error pops up.
How interesting - so it seems that we’ve filtered locators by default from getting cbId attributes - which may be debatable about whether that was the right decision.
In this case however, I’d say the locator should not remain there after having build the template. I think this error may already be avoided if you have “Delete placeholders” or something enabled. I believe that’s in settings?
(Unless you absolutely need the placeholders to be maintained.)
A workaround for now may be to force generate an id in the workfile template itself. Select the placeholder locator and run this in Python in Maya:
"""Force generate new cbId values on selected nodes, even if they don't have any yet"""
from ayon_maya.api import lib
from maya import cmds
def force_generate_ids(nodes):
"""Generate new cbIds on selected nodes, even if they don't have any yet"""
with lib.undo_chunk():
for node, id in lib.generate_ids(nodes):
print("Setting cbId on {node}: {id}".format(node=node, id=id))
lib.set_id(node, id, overwrite=True)
nodes = cmds.ls(dag=True, sl=True, long=True)
nodes += cmds.ls(sl=True, long=True) # also include non-dag nodes
force_generate_ids(nodes)
That way it would have the necessary attribute. But then you may get into the case that it doesn’t allow it to contain ids that are not relevant to the asset you’re publishing in that particular context. So I’m not sure that really solves it.
Ah, look at that - I suppose the Script Placeholder happens to be useful!
You could even create the Script Placeholder as object set if I’m not mistaken. From which, in the script, you can trivial access its members… as such, you can then just make the placeholder to delete a member of the script placeholder object set instead of having to hardcode the name.
Have fun!
from maya import cmds
placeholder_node = placeholder.scene_identifier
members = cmds.sets(placeholder_node, query=True)
if members:
cmds.delete(members) # Delete any members
cmds.delete(placeholder_node) # Cleanup self