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

Commit

Permalink
commit 7c2bb2d
Browse files Browse the repository at this point in the history
Author: Thomas Fricard <[email protected]>
Date:   Mon May 15 17:12:13 2023 +0200

    cosmetic refactoring

commit 6fcb0a6
Author: Thomas Fricard <[email protected]>
Date:   Mon May 15 16:55:19 2023 +0200

    check id attribute before family attribute

commit df6cc8c
Author: Thomas Fricard <[email protected]>
Date:   Fri May 12 16:01:52 2023 +0200

    verify that 'family' attributes exists and equals to 'render'

commit 5ae1847
Author: Thomas Fricard <[email protected]>
Date:   Fri May 12 15:58:05 2023 +0200

    change function name + docstrings

commit ff09bbb
Author: Thomas Fricard <[email protected]>
Date:   Fri May 12 11:48:43 2023 +0200

    add a 'type' key to the 'include handles' setting of maya

commit ec96832
Author: Thomas Fricard <[email protected]>
Date:   Wed May 3 15:32:06 2023 +0200

    merge and refactor functions to updte asset frame range

commit 661f494
Author: Thomas Fricard <[email protected]>
Date:   Tue Apr 18 10:03:24 2023 +0200

    add 'instances' to reset_frame_range function arguments and make sure it does not update frame range instances on creating render settings

commit a10ecfc
Merge: 19836b3 196f698
Author: Thomas Fricard <[email protected]>
Date:   Tue Apr 18 09:32:32 2023 +0200

    Merge branch '346-fix-studio-openpype-udpate-frame-range-of-scene-doesn-t-update-frame-range-in-animation-instance' of github.com:quadproduction/OpenPype into 346-fix-studio-openpype-udpate-frame-range-of-scene-doesn-t-update-frame-range-in-animation-instance

commit 19836b3
Author: Thomas Fricard <[email protected]>
Date:   Tue Apr 18 09:31:27 2023 +0200

    change key and label to make the setting more understandable

commit 196f698
Merge: 155a0c2 515c0ac
Author: Thomas Fricard <[email protected]>
Date:   Thu Apr 13 11:06:26 2023 +0200

    Merge branch 'develop' into 346-fix-studio-openpype-udpate-frame-range-of-scene-doesn-t-update-frame-range-in-animation-instance

commit 155a0c2
Author: Thomas Fricard <[email protected]>
Date:   Thu Apr 13 10:57:53 2023 +0200

    resolve conflicts

commit 6a6c9e0
Author: Thomas Fricard <[email protected]>
Date:   Wed Apr 12 14:07:19 2023 +0200

    check if update instances is enabled in settings

commit 9211c4a
Author: Thomas Fricard <[email protected]>
Date:   Wed Apr 12 13:58:40 2023 +0200

    add a setting in maya project settings to enable updating animation instances

commit fde0b50
Author: Thomas Fricard <[email protected]>
Date:   Tue Apr 11 16:58:37 2023 +0200

    check if attribute exsits before modifying it

commit 38eed31
Author: Thomas Fricard <[email protected]>
Date:   Wed Apr 5 15:26:04 2023 +0200

    update animation instance frames attribute on reset frame range

commit dc47ca9
Author: Thomas Fricard <[email protected]>
Date:   Fri Mar 31 15:56:19 2023 +0200

    get instances and set frameStart attribute

commit 0932341
Author: Thomas Fricard <[email protected]>
Date:   Wed May 17 12:47:17 2023 +0200

    call reset_frame_range function for instances after importing

commit 4de8e6e
Author: Thomas Fricard <[email protected]>
Date:   Mon May 15 17:12:13 2023 +0200

    cosmetic refactoring

commit efe2dbb
Author: Thomas Fricard <[email protected]>
Date:   Mon May 15 16:55:19 2023 +0200

    check id attribute before family attribute

commit 2379c5c
Author: Thomas Fricard <[email protected]>
Date:   Fri May 12 16:01:52 2023 +0200

    verify that 'family' attributes exists and equals to 'render'

commit 3a57274
Author: Thomas Fricard <[email protected]>
Date:   Fri May 12 15:58:05 2023 +0200

    change function name + docstrings

commit 7f68109
Author: Thomas Fricard <[email protected]>
Date:   Fri May 12 11:48:43 2023 +0200

    add a 'type' key to the 'include handles' setting of maya

commit 58fb563
Author: Thomas Fricard <[email protected]>
Date:   Wed May 3 15:32:06 2023 +0200

    merge and refactor functions to updte asset frame range

commit 49401c7
Author: Thomas Fricard <[email protected]>
Date:   Tue Apr 18 10:03:24 2023 +0200

    add 'instances' to reset_frame_range function arguments and make sure it does not update frame range instances on creating render settings

commit 8c0c60d
Author: Thomas Fricard <[email protected]>
Date:   Tue Apr 18 09:31:27 2023 +0200

    change key and label to make the setting more understandable

commit bdcdab2
Author: Thomas Fricard <[email protected]>
Date:   Thu Apr 13 10:57:53 2023 +0200

    resolve conflicts

commit 9040302
Author: Thomas Fricard <[email protected]>
Date:   Wed Apr 12 14:07:19 2023 +0200

    check if update instances is enabled in settings

commit cd884e8
Author: Thomas Fricard <[email protected]>
Date:   Wed Apr 12 13:58:40 2023 +0200

    add a setting in maya project settings to enable updating animation instances

commit 981c0b1
Author: Thomas Fricard <[email protected]>
Date:   Tue Apr 11 16:58:37 2023 +0200

    check if attribute exsits before modifying it

commit 1755ce4
Author: Thomas Fricard <[email protected]>
Date:   Wed Apr 5 15:26:04 2023 +0200

    update animation instance frames attribute on reset frame range

commit fdf6f43
Author: Thomas Fricard <[email protected]>
Date:   Fri Mar 31 15:56:19 2023 +0200

    get instances and set frameStart attribute
  • Loading branch information
ClementHector committed Jun 27, 2023
1 parent eb7aceb commit 92f5046
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 27 deletions.
77 changes: 53 additions & 24 deletions openpype/hosts/maya/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -2261,7 +2261,7 @@ def get_frame_range(include_animation_range=False):
return 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 @@ -2270,6 +2270,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 Down Expand Up @@ -2300,6 +2302,12 @@ def reset_frame_range(playback=True, render=True, fps=True):
cmds.setAttr("defaultRenderGlobals.startFrame", animation_start)
cmds.setAttr("defaultRenderGlobals.endFrame", animation_end)

if instances:
project_name = get_current_project_name()
settings = get_project_settings(project_name)
if settings["maya"]["update_publishable_frame_range"]["enabled"]:
update_instances_frame_range()


def reset_scene_resolution():
"""Apply the scene resolution from the project definition
Expand Down Expand Up @@ -3129,31 +3137,52 @@ def remove_render_layer_observer():
pass


def update_content_on_context_change():
"""
This will update scene content to match new asset on context change
def update_instances_frame_range():
"""Update 'frameStart', 'frameEnd', 'handleStart', 'handleEnd' and 'asset'
attributes of sets that got one, execpt if instance family is 'render'
"""
scene_sets = cmds.listSets(allSets=True)
collected_instances = cmds.ls(
"*.id",
long=True,
type="objectSet",
recursive=True,
objectsOnly=True
)
asset_doc = get_current_project_asset()
new_asset = asset_doc["name"]
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 "frameStart" in attr:
cmds.setAttr("{}.frameStart".format(s),
new_data["frameStart"])
if "frameEnd" in attr:
cmds.setAttr("{}.frameEnd".format(s),
new_data["frameEnd"],)
except ValueError:
pass

asset_data = asset_doc["data"]
frames_attributes = {
'frameStart': asset_data["frameStart"],
'frameEnd': asset_data["frameEnd"],
'handleStart': asset_data["handleStart"],
'handleEnd': asset_data["handleEnd"],
'asset': asset_doc['name']
}

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

if (
cmds.attributeQuery('family', node=instance, exists=True) and
cmds.getAttr("{}.family".format(instance)) == "render"
):
continue

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


def show_message(title, msg):
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
2 changes: 1 addition & 1 deletion openpype/hosts/maya/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ def on_task_changed():

with lib.suspended_refresh():
lib.set_context_settings()
lib.update_content_on_context_change()
lib.update_instances_frame_range()

msg = " project: {}\n asset: {}\n task:{}".format(
legacy_io.active_project(),
Expand Down
3 changes: 2 additions & 1 deletion openpype/hosts/maya/api/workfile_template_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
WorkfileBuildPlaceholderDialog,
)

from .lib import read, imprint, get_main_window
from .lib import read, imprint, reset_frame_range, get_main_window

PLACEHOLDER_SET = "PLACEHOLDERS_SET"

Expand Down Expand Up @@ -251,6 +251,7 @@ def cleanup_placeholder(self, placeholder, failed):
cmds.sets(node, addElement=PLACEHOLDER_SET)
cmds.hide(node)
cmds.setAttr(node + ".hiddenInOutliner", True)
reset_frame_range(playback=False, render=False, fps=False)

def load_succeed(self, placeholder, container):
self._parent_in_hierarchy(placeholder, container)
Expand Down
3 changes: 3 additions & 0 deletions openpype/settings/defaults/project_settings/maya.json
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,9 @@
"include_handles_default": false,
"per_task_type": []
},
"update_publishable_frame_range": {
"enabled": true
},
"scriptsmenu": {
"name": "OpenPype Tools",
"definition": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,24 @@
}
]
},
{
"type": "dict",
"collapsible": true,
"key": "update_publishable_frame_range",
"label": "Update publishable instances on Reset Frame Range",
"checkbox_key": "enabled",
"children": [
{
"type": "label",
"label": "If enabled, the frame range and the handles of all the publishable instances will be updated when using the 'Reset Frame Range' functionality"
},
{
"type": "boolean",
"key": "enabled",
"label": "Enabled"
}
]
},
{
"type": "dict",
"key": "include_handles",
Expand Down

0 comments on commit 92f5046

Please sign in to comment.