fix 'update_content_on_context_change' in maya

This commit is contained in:
Jakub Trllo 2024-02-21 10:38:21 +01:00
parent 9677b16fc3
commit 7e78937e31

View file

@ -24,7 +24,8 @@ from ayon_core.client import (
get_asset_by_name,
get_subsets,
get_last_versions,
get_representation_by_name
get_representation_by_name,
get_asset_name_identifier,
)
from ayon_core.settings import get_project_settings
from ayon_core.pipeline import (
@ -3143,21 +3144,25 @@ def fix_incompatible_containers():
def update_content_on_context_change():
"""
This will update scene content to match new asset on context change
This will update scene content to match new folder on context change
"""
scene_sets = cmds.listSets(allSets=True)
asset_doc = get_current_project_asset()
new_asset = asset_doc["name"]
new_folder_path = get_asset_name_identifier(asset_doc)
new_data = asset_doc["data"]
for s in scene_sets:
try:
if cmds.getAttr("{}.id".format(s)) == "pyblish.avalon.instance":
attr = cmds.listAttr(s)
print(s)
if "asset" in attr:
print(" - setting asset to: [ {} ]".format(new_asset))
cmds.setAttr("{}.asset".format(s),
new_asset, type="string")
if "folderPath" in attr:
print(
" - setting folder to: [ {} ]".format(new_folder_path)
)
cmds.setAttr(
"{}.folderPath".format(s),
new_folder_path, type="string"
)
if "frameStart" in attr:
cmds.setAttr("{}.frameStart".format(s),
new_data["frameStart"])