Skip to content

Commit

Permalink
Merge pull request #4470 from quadproduction/277-template-builder-doe…
Browse files Browse the repository at this point in the history
…s-not-update-instance-creator-asset-field
  • Loading branch information
antirotor committed Feb 16, 2023
2 parents 973aa11 + 035c888 commit 7ba5440
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions openpype/hosts/maya/api/workfile_template_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from maya import cmds

from openpype.pipeline import registered_host
from openpype.pipeline import registered_host, get_current_asset_name
from openpype.pipeline.workfile.workfile_template_builder import (
TemplateAlreadyImported,
AbstractTemplateBuilder,
Expand Down Expand Up @@ -41,10 +41,27 @@ def import_template(self, path):
))

cmds.sets(name=PLACEHOLDER_SET, empty=True)
cmds.file(path, i=True, returnNewNodes=True)
new_nodes = cmds.file(path, i=True, returnNewNodes=True)

cmds.setAttr(PLACEHOLDER_SET + ".hiddenInOutliner", True)

imported_sets = cmds.ls(new_nodes, set=True)
if not imported_sets:
return True

# update imported sets information
asset_name = get_current_asset_name()
for node in imported_sets:
if not cmds.attributeQuery("id", node=node, exists=True):
continue
if cmds.getAttr("{}.id".format(node)) != "pyblish.avalon.instance":
continue
if not cmds.attributeQuery("asset", node=node, exists=True):
continue

cmds.setAttr(
"{}.asset".format(node), asset_name, type="string")

return True


Expand Down

0 comments on commit 7ba5440

Please sign in to comment.