Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
check if update instances is enabled in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Fricard committed Apr 12, 2023
1 parent 9211c4a commit 6a6c9e0
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions openpype/hosts/maya/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -2076,6 +2076,7 @@ def reset_frame_range():
project_name = legacy_io.active_project()
asset_name = legacy_io.Session["AVALON_ASSET"]
asset = get_asset_by_name(project_name, asset_name)
settings = get_project_settings(project_name)

frame_start = asset["data"].get("frameStart")
frame_end = asset["data"].get("frameEnd")
Expand Down Expand Up @@ -2111,31 +2112,33 @@ def reset_frame_range():
cmds.setAttr("defaultRenderGlobals.startFrame", frame_start)
cmds.setAttr("defaultRenderGlobals.endFrame", frame_end)

instances = cmds.ls(
"*.id",
long=True,
type="objectSet",
recursive=True,
objectsOnly=True
)
frames_attributes = {
'frameStart': frame_start,
'frameEnd': frame_end,
'handleStart': handle_start,
'handleEnd': handle_end
}
# Update animation instances attributes if enabled in settings
if settings["maya"]["update_instances"]["enabled"]:
instances = cmds.ls(
"*.id",
long=True,
type="objectSet",
recursive=True,
objectsOnly=True
)
frames_attributes = {
'frameStart': frame_start,
'frameEnd': frame_end,
'handleStart': handle_start,
'handleEnd': handle_end
}

for instance in instances:
id_attr = "{}.id".format(instance)
if cmds.getAttr(id_attr) != "pyblish.avalon.instance":
continue
for instance in instances:
id_attr = "{}.id".format(instance)
if cmds.getAttr(id_attr) != "pyblish.avalon.instance":
continue

for key, value in frames_attributes.items():
if cmds.attributeQuery(key, node=instance, exists=True):
cmds.setAttr(
"{}.{}".format(instance, key),
value
)
for key, value in frames_attributes.items():
if cmds.attributeQuery(key, node=instance, exists=True):
cmds.setAttr(
"{}.{}".format(instance, key),
value
)


def reset_scene_resolution():
Expand Down

0 comments on commit 6a6c9e0

Please sign in to comment.