Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
e8d6f1d
Pull Fusion integration from `colorbleed`
BigRoy Feb 20, 2022
e72c768
fusion: adding reset resolution
jakubjezek001 Feb 17, 2022
1b40d51
Fix hound issues
BigRoy Feb 20, 2022
43be200
Avoid assigning a lambda expression
BigRoy Feb 20, 2022
860f159
Fix double "render" family
BigRoy Feb 20, 2022
cdca18e
Fusion: Add support for open last workfile
BigRoy Feb 22, 2022
4e614c8
Fix typo + wrong label
BigRoy Feb 22, 2022
959aa2a
Remove duplicate script that has more recent version in openpype/host…
BigRoy Feb 22, 2022
51ef4ce
Move Comp scripts to an OpenPype submenu to clarify those are OpenPyp…
BigRoy Feb 22, 2022
2f9eb8f
Fix on_pyblish_instance_toggled arguments
BigRoy Feb 22, 2022
4c81d1d
Merge remote-tracking branch 'upstream/develop' into fusion_integrati…
BigRoy Mar 17, 2022
4539166
Fix merge conflict and remove fusion_switch_shot.py again
BigRoy Mar 17, 2022
9bb5626
Merge remote-tracking branch 'upstream/develop' into fusion_integrati…
BigRoy Mar 29, 2022
0941c18
Use new OpenPype Event System implemented with #2846
BigRoy Mar 29, 2022
5689287
Cosmetics
BigRoy Mar 30, 2022
2d40617
Shut down fusionscript process when OpenPype menu gets closed along w…
BigRoy Mar 30, 2022
53382a1
Draft implementation of Fusion heartbeat/pulse so UI closes after Fus…
BigRoy Mar 30, 2022
84ab536
Take the `interval` variable into the run thread - not sure if really…
BigRoy Mar 30, 2022
0e9dd34
Fix code
BigRoy Mar 30, 2022
1a1c9f3
Merge remote-tracking branch 'upstream/develop' into fusion_integrati…
BigRoy Sep 13, 2022
229d31b
Collect global in/out as handles
BigRoy Sep 13, 2022
8d4d80c
Be more explicit about the to render frame range (include rendering o…
BigRoy Sep 13, 2022
e12de9b
Do not auto-add ftrack family
BigRoy Sep 13, 2022
df370e5
Refactor to match with API changes of OpenPype
BigRoy Sep 15, 2022
618e626
Allow to minimize the menu so it doesn't always have to stay on top
BigRoy Sep 15, 2022
83fb00e
Get start frame including handles
BigRoy Sep 15, 2022
0806534
Return early if no need to shift
BigRoy Sep 15, 2022
5058de2
Fix return value
BigRoy Sep 15, 2022
df4d92d
Hack in support for Fusion 18
BigRoy Sep 15, 2022
0e4a73f
Fusion: Set OCIO project setting and set OCIO env var on launch
BigRoy Sep 15, 2022
cd40fab
Add Fusion 18 application to defaults
BigRoy Sep 15, 2022
839ded2
Make `handle_start` and `handle_end` more explicit arguments
BigRoy Sep 15, 2022
508b179
Move Fusion OCIO settings out of anatomy into project settings
BigRoy Sep 16, 2022
7aa9058
Use new settings location
BigRoy Sep 16, 2022
bd3f6ac
Refactor `HOST_DIR` to `FUSION_HOST_DIR`
BigRoy Sep 19, 2022
daf2912
Refactor `HOST_DIR` to `FUSION_HOST_DIR`
BigRoy Sep 19, 2022
5694cff
Use `FUSION_PYTHON3_HOME` instead of `FUSION16_PYTHON36_HOME` as inpu…
BigRoy Sep 19, 2022
c965b35
Fix typo
BigRoy Sep 19, 2022
4154f76
Implement Set Asset Resolution
BigRoy Sep 19, 2022
830ccf0
Clarify function names
BigRoy Sep 19, 2022
863265f
Set `OPENPYPE_LOG_NO_COLORS` in addon
BigRoy Sep 19, 2022
df330e1
Update defaults for Fusion environment
BigRoy Sep 19, 2022
c725c6a
Tweak docstrings
BigRoy Sep 19, 2022
1f035a1
Store link to menu so we can get access to it elsewhere
BigRoy Sep 19, 2022
23b6a35
Add after open callback to show popup about outdated containers
BigRoy Sep 19, 2022
30ee358
Move `get_current_comp` and `comp_lock_and_undo_chunk` to `lib`
BigRoy Sep 19, 2022
9dda39a
Remove unused imports
BigRoy Sep 19, 2022
15c3b06
Add validate comp prefs on scene before save and after scene open
BigRoy Sep 19, 2022
fb940c5
Don't error if "show" is clicked but comp is closed already
BigRoy Sep 19, 2022
1013a29
Remove double space
BigRoy Sep 19, 2022
2df5d87
Remove before save callback since it runs BEFORE the task change maki…
BigRoy Sep 20, 2022
4c884ed
Add a pop-up about invalid comp configuration
BigRoy Sep 20, 2022
794e8a9
Shush hound
BigRoy Sep 20, 2022
64ef00b
Set OpenPype icon for menu
BigRoy Sep 20, 2022
a8d9047
Remove redundant Spacer widget and use `QVBoxLayout.addSpacing`
BigRoy Sep 20, 2022
1ce7e69
Remove "Clicked {button}" print statements
BigRoy Sep 20, 2022
1561032
Get current comp once and as early as possible
BigRoy Sep 20, 2022
6bcb9dd
Remove `get_additional_data`
BigRoy Sep 20, 2022
3c134ec
Remove redundant saying "installed" even though it's midway during in…
BigRoy Sep 20, 2022
0b525fa
Cleanup Create EXR saver logic
BigRoy Sep 20, 2022
b62d127
Clean up docstring
BigRoy Sep 20, 2022
604940c
Merge remote-tracking branch 'upstream/develop' into fusion_integrati…
BigRoy Sep 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions openpype/hooks/pre_add_last_workfile_arg.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class AddLastWorkfileToLaunchArgs(PreLaunchHook):
"hiero",
"houdini",
"nukestudio",
"fusion",
"blender",
"photoshop",
"tvpaint",
Expand Down
9 changes: 9 additions & 0 deletions openpype/hosts/fusion/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,14 @@ def get_launch_hook_paths(self, app):
os.path.join(FUSION_HOST_DIR, "hooks")
]

def add_implementation_envs(self, env, _app):
# Set default values if are not already set via settings
defaults = {
"OPENPYPE_LOG_NO_COLORS": "Yes"
}
for key, value in defaults.items():
if not env.get(key):
env[key] = value

def get_workfile_extensions(self):
return [".comp"]
18 changes: 8 additions & 10 deletions openpype/hosts/fusion/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
ls,

imprint_container,
parse_container,

get_current_comp,
comp_lock_and_undo_chunk
parse_container
)

from .workio import (
Expand All @@ -22,8 +19,10 @@

from .lib import (
maintained_selection,
get_additional_data,
update_frame_range
update_frame_range,
set_asset_framerange,
get_current_comp,
comp_lock_and_undo_chunk
)

from .menu import launch_openpype_menu
Expand All @@ -38,9 +37,6 @@
"imprint_container",
"parse_container",

"get_current_comp",
"comp_lock_and_undo_chunk",

# workio
"open_file",
"save_file",
Expand All @@ -51,8 +47,10 @@

# lib
"maintained_selection",
"get_additional_data",
"update_frame_range",
"set_asset_framerange",
"get_current_comp",
"comp_lock_and_undo_chunk",

# menu
"launch_openpype_menu",
Expand Down
153 changes: 136 additions & 17 deletions openpype/hosts/fusion/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from Qt import QtGui

from openpype.lib import Logger
from openpype.client import (
get_asset_by_name,
get_subset_by_name,
Expand All @@ -17,13 +18,14 @@
switch_container,
legacy_io,
)
from .pipeline import get_current_comp, comp_lock_and_undo_chunk
from openpype.pipeline.context_tools import get_current_project_asset

self = sys.modules[__name__]
self._project = None


def update_frame_range(start, end, comp=None, set_render_range=True):
def update_frame_range(start, end, comp=None, set_render_range=True,
handle_start=0, handle_end=0):
"""Set Fusion comp's start and end frame range

Args:
Expand All @@ -32,6 +34,8 @@ def update_frame_range(start, end, comp=None, set_render_range=True):
comp (object, Optional): comp object from fusion
set_render_range (bool, Optional): When True this will also set the
composition's render start and end frame.
handle_start (float, int, Optional): frame handles before start frame
handle_end (float, int, Optional): frame handles after end frame

Returns:
None
Expand All @@ -41,11 +45,16 @@ def update_frame_range(start, end, comp=None, set_render_range=True):
if not comp:
comp = get_current_comp()

# Convert any potential none type to zero
handle_start = handle_start or 0
handle_end = handle_end or 0

attrs = {
"COMPN_GlobalStart": start,
"COMPN_GlobalEnd": end
"COMPN_GlobalStart": start - handle_start,
"COMPN_GlobalEnd": end + handle_end
}

# set frame range
if set_render_range:
attrs.update({
"COMPN_RenderStart": start,
Expand All @@ -56,24 +65,116 @@ def update_frame_range(start, end, comp=None, set_render_range=True):
comp.SetAttrs(attrs)


def get_additional_data(container):
"""Get Fusion related data for the container
def set_asset_framerange():
"""Set Comp's frame range based on current asset"""
asset_doc = get_current_project_asset()
start = asset_doc["data"]["frameStart"]
end = asset_doc["data"]["frameEnd"]
handle_start = asset_doc["data"]["handleStart"]
handle_end = asset_doc["data"]["handleEnd"]
update_frame_range(start, end, set_render_range=True,
handle_start=handle_start,
handle_end=handle_end)

Args:
container(dict): the container found by the ls() function

Returns:
dict
def set_asset_resolution():
"""Set Comp's resolution width x height default based on current asset"""
asset_doc = get_current_project_asset()
width = asset_doc["data"]["resolutionWidth"]
height = asset_doc["data"]["resolutionHeight"]
comp = get_current_comp()

print("Setting comp frame format resolution to {}x{}".format(width,
height))
comp.SetPrefs({
"Comp.FrameFormat.Width": width,
"Comp.FrameFormat.Height": height,
})


def validate_comp_prefs(comp=None):
"""Validate current comp defaults with asset settings.

Validates fps, resolutionWidth, resolutionHeight, aspectRatio.

This does *not* validate frameStart, frameEnd, handleStart and handleEnd.
"""

tool = container["_tool"]
tile_color = tool.TileColor
if tile_color is None:
return {}
if comp is None:
comp = get_current_comp()

return {"color": QtGui.QColor.fromRgbF(tile_color["R"],
tile_color["G"],
tile_color["B"])}
log = Logger.get_logger("validate_comp_prefs")

fields = [
"name",
"data.fps",
"data.resolutionWidth",
"data.resolutionHeight",
"data.pixelAspect"
]
asset_doc = get_current_project_asset(fields=fields)
asset_data = asset_doc["data"]

comp_frame_format_prefs = comp.GetPrefs("Comp.FrameFormat")

# Pixel aspect ratio in Fusion is set as AspectX and AspectY so we convert
# the data to something that is more sensible to Fusion
asset_data["pixelAspectX"] = asset_data.pop("pixelAspect")
asset_data["pixelAspectY"] = 1.0

validations = [
("fps", "Rate", "FPS"),
("resolutionWidth", "Width", "Resolution Width"),
("resolutionHeight", "Height", "Resolution Height"),
("pixelAspectX", "AspectX", "Pixel Aspect Ratio X"),
("pixelAspectY", "AspectY", "Pixel Aspect Ratio Y")
]

invalid = []
for key, comp_key, label in validations:
asset_value = asset_data[key]
comp_value = comp_frame_format_prefs.get(comp_key)
if asset_value != comp_value:
# todo: Actually show dialog to user instead of just logging
log.warning(
"Comp {pref} {value} does not match asset "
"'{asset_name}' {pref} {asset_value}".format(
pref=label,
value=comp_value,
asset_name=asset_doc["name"],
asset_value=asset_value)
)

invalid_msg = "{} {} should be {}".format(label,
comp_value,
asset_value)
invalid.append(invalid_msg)

if invalid:

def _on_repair():
attributes = dict()
for key, comp_key, _label in validations:
value = asset_data[key]
comp_key_full = "Comp.FrameFormat.{}".format(comp_key)
attributes[comp_key_full] = value
comp.SetPrefs(attributes)

from . import menu
from openpype.widgets import popup
from openpype.style import load_stylesheet
dialog = popup.Popup(parent=menu.menu)
dialog.setWindowTitle("Fusion comp has invalid configuration")

msg = "Comp preferences mismatches '{}'".format(asset_doc["name"])
msg += "\n" + "\n".join(invalid)
dialog.setMessage(msg)
dialog.setButtonText("Repair")
dialog.on_clicked.connect(_on_repair)
dialog.show()
dialog.raise_()
dialog.activateWindow()
dialog.setStyleSheet(load_stylesheet())


def switch_item(container,
Expand Down Expand Up @@ -195,3 +296,21 @@ def get_frame_path(path):
padding = 4 # default Fusion padding

return filename, padding, ext


def get_current_comp():
"""Hack to get current comp in this session"""
fusion = getattr(sys.modules["__main__"], "fusion", None)
return fusion.CurrentComp if fusion else None


@contextlib.contextmanager
def comp_lock_and_undo_chunk(comp, undo_queue_name="Script CMD"):
"""Lock comp and open an undo chunk during the context"""
try:
comp.Lock()
comp.StartUndo(undo_queue_name)
yield
finally:
comp.Unlock()
comp.EndUndo()
Loading