Skip to content

Commit

Permalink
Fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
ccaillot committed Nov 2, 2023
2 parents 0f546ea + 2b073b4 commit 751a072
Show file tree
Hide file tree
Showing 54 changed files with 1,974 additions and 1,008 deletions.
3 changes: 2 additions & 1 deletion openpype/hosts/aftereffects/plugins/load/load_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class FileLoader(api.AfterEffectsLoader):
"render",
"prerender",
"review",
"audio"]
"audio",
"workfile"]
representations = ["*"]

def load(self, context, name=None, namespace=None, data=None):
Expand Down
11 changes: 10 additions & 1 deletion openpype/hosts/hiero/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,9 @@ def __init__(self, cls, track_item, **kwargs):
# adding ui inputs if any
self.ui_inputs = kwargs.get("ui_inputs", {})

project_settings = get_current_project_settings()
self.symlink = project_settings["hiero"]["create"]["CreateShotClip"]["symlink"] # noqa

# populate default data before we get other attributes
self._populate_track_item_default_data()

Expand Down Expand Up @@ -751,7 +754,8 @@ def _populate_track_item_default_data(self):
"_track_": self.track_name,
"_clip_": self.ti_name,
"_trackIndex_": self.track_index,
"_clipIndex_": self.ti_index
"_clipIndex_": self.ti_index,
"_symlink_": self.symlink
}

def _populate_attributes(self):
Expand All @@ -775,6 +779,11 @@ def _populate_attributes(self):
self.hierarchy_data = self.ui_inputs.get(
"hierarchyData", {}).get("value") or \
self.track_item_default_data.copy()

ui_symlink = self.ui_inputs.get(
"hierarchyData", {}).get("value").get("symlink").get("value")
self.hierarchy_data["symlink"].update({"value": str(ui_symlink)})

self.count_from = self.ui_inputs.get(
"countFrom", {}).get("value") or self.count_from_default
self.count_steps = self.ui_inputs.get(
Expand Down
9 changes: 8 additions & 1 deletion openpype/hosts/hiero/plugins/create/create_shot_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,14 @@ class CreateShotClip(phiero.Creator):
"label": "{shot}",
"target": "tag",
"toolTip": "Name of shot. `#` is converted to paded number. \nAlso could be used with usable tokens:\n\t{_clip_}: name of used clip\n\t{_track_}: name of parent track layer\n\t{_sequence_}: name of parent sequence (timeline)", # noqa
"order": 4}
"order": 4},
"symlink": {
"value": False,
"type": "QCheckBox",
"label": "Publish using symlink",
"target": "tag",
"toolTip": "Publish symlinks, don't copy files",
"order": 5}
}
},
"verticalSync": {
Expand Down
112 changes: 86 additions & 26 deletions openpype/hosts/maya/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,28 @@ def imprint(node, data):
add_type = {"attributeType": "enum", "enumName": ":".join(value)}
set_type = {"keyable": False, "channelBox": True}
value = 0 # enum default
elif isinstance(value, dict):
for key, group_list in value.items():
cmds.addAttr(
node,
longName=key,
numberOfChildren=len(group_list),
attributeType="compound"
)
for group in group_list:
cmds.addAttr(
node,
longName=group,
attributeType="bool",
parent=key
)
continue
else:
raise TypeError("Unsupported type: %r" % type(value))

cmds.addAttr(node, longName=key, **add_type)
cmds.setAttr(node + "." + key, value, **set_type)
if not isinstance(value, dict):
cmds.addAttr(node, longName=key, **add_type)
cmds.setAttr(node + "." + key, value, **set_type)


def lsattr(attr, value=None):
Expand Down Expand Up @@ -2284,6 +2301,7 @@ def get_frame_range(include_animation_range=False):
"handleStart": handle_start,
"handleEnd": handle_end
}

if include_animation_range:
# The animation range values are only included to define whether
# the Maya time slider should include the handles or not.
Expand All @@ -2307,13 +2325,15 @@ def get_frame_range(include_animation_range=False):
animation_start -= int(handle_start)
animation_end += int(handle_end)

frame_range["frameStart"] = animation_start
frame_range["frameEnd"] = animation_end
frame_range["animationStart"] = animation_start
frame_range["animationEnd"] = animation_end

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 @@ -2322,6 +2342,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:
set_scene_fps(get_fps_for_current_context())
Expand Down Expand Up @@ -2349,6 +2371,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 @@ -3169,31 +3197,63 @@ def remove_render_layer_observer():
pass


def update_content_on_context_change():
def iter_publish_instances():
"""Iterate over publishable instances (their objectSets).
"""
This will update scene content to match new asset on context change
for node in cmds.ls(
"*.id",
long=True,
type="objectSet",
recursive=True,
objectsOnly=True
):
if cmds.getAttr("{}.id".format(node)) != "pyblish.avalon.instance":
continue
yield node


def update_instances_asset_name():
"""Update 'asset' attribute of publishable instances (their objectSets)
that got one.
"""
scene_sets = cmds.listSets(allSets=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

for instance in iter_publish_instances():
if not cmds.attributeQuery("asset", node=instance, exists=True):
continue
attr = "{}.asset".format(instance)
cmds.setAttr(attr, get_current_asset_name(), type="string")


def update_instances_frame_range():
"""Update 'frameStart', 'frameEnd', 'handleStart', 'handleEnd' and 'fps'
attributes of publishable instances (their objectSets) that got one.
"""

attributes = ["frameStart", "frameEnd", "handleStart", "handleEnd", "fps"]

attrs_per_instance = {}
for instance in iter_publish_instances():
instance_attrs = [
attr for attr in attributes
if cmds.attributeQuery(attr, node=instance, exists=True)
]

if instance_attrs:
attrs_per_instance[instance] = instance_attrs

if not attrs_per_instance:
# no instances with any frame related attributes
return

fields = ["data.{}".format(key) for key in attributes]
asset_doc = get_current_project_asset(fields=fields)
asset_data = asset_doc["data"]

for node, attrs in attrs_per_instance.items():
for attr in attrs:
plug = "{}.{}".format(node, attr)
value = asset_data[attr]
cmds.setAttr(plug, 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
3 changes: 2 additions & 1 deletion openpype/hosts/maya/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,8 @@ def on_task_changed():

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


def before_workfile_open():
Expand Down
11 changes: 10 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,14 @@
WorkfileBuildPlaceholderDialog,
)

from .lib import read, imprint, get_reference_node, get_main_window
from .lib import (
read,
imprint,
get_reference_node,
get_main_window,
update_instances_frame_range,
update_instances_asset_name,
)

PLACEHOLDER_SET = "PLACEHOLDERS_SET"

Expand Down Expand Up @@ -254,6 +261,8 @@ def post_placeholder_process(self, placeholder, failed):
cmds.sets(node, addElement=PLACEHOLDER_SET)
cmds.hide(node)
cmds.setAttr(node + ".hiddenInOutliner", True)
update_instances_frame_range()
update_instances_asset_name()

def delete_placeholder(self, placeholder):
"""Remove placeholder if building was successful"""
Expand Down
Loading

0 comments on commit 751a072

Please sign in to comment.