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

Commit

Permalink
add 'instances' to reset_frame_range function arguments and make sure…
Browse files Browse the repository at this point in the history
… it does not update frame range instances on creating render settings
  • Loading branch information
Thomas Fricard committed Apr 18, 2023
1 parent a10ecfc commit 661f494
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 29 deletions.
63 changes: 35 additions & 28 deletions openpype/hosts/maya/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -2190,7 +2190,7 @@ def get_frame_range():
}


def reset_frame_range(playback=True, render=True, fps=True):
def reset_frame_range(playback=True, render=True, fps=True, instances=True):
"""Set frame range to current asset
Args:
Expand All @@ -2199,6 +2199,8 @@ def reset_frame_range(playback=True, render=True, fps=True):
render (bool, Optional): Whether to set the maya render frame range.
Defaults to True.
fps (bool, Optional): Whether to set scene FPS. Defaults to True.
instances (bool, Optional): Whether to update publishable instances.
Defaults to True.
"""
if fps:
fps = convert_to_maya_fps(
Expand All @@ -2224,35 +2226,40 @@ def reset_frame_range(playback=True, render=True, fps=True):
cmds.setAttr("defaultRenderGlobals.startFrame", frame_start)
cmds.setAttr("defaultRenderGlobals.endFrame", frame_end)

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

for instance in collected_instances:
family_attr = "{}.family".format(instance)
if family_attr == "render":
continue

for instance in instances:
id_attr = "{}.id".format(instance)
if cmds.getAttr(id_attr) != "pyblish.avalon.instance":
continue
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
7 changes: 6 additions & 1 deletion openpype/hosts/maya/api/lib_rendersettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,12 @@ def _set_arnold_settings(self, width, height):
cmds.setAttr(
"defaultArnoldDriver.mergeAOVs", multi_exr)
self._additional_attribs_setter(additional_options)
reset_frame_range(playback=False, fps=False, render=True)
reset_frame_range(
playback=False,
fps=False,
render=True,
instances=False
)

def _set_redshift_settings(self, width, height):
"""Sets settings for Redshift."""
Expand Down

0 comments on commit 661f494

Please sign in to comment.