mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Fix OpenPype not initialized on Houdini launch when opening with last workfile
This commit is contained in:
parent
b8d6e2181f
commit
43010a490e
2 changed files with 76 additions and 4 deletions
|
|
@ -17,7 +17,6 @@ class AddLastWorkfileToLaunchArgs(PreLaunchHook):
|
|||
"nuke",
|
||||
"nukex",
|
||||
"hiero",
|
||||
"houdini",
|
||||
"nukestudio",
|
||||
"blender",
|
||||
"photoshop",
|
||||
|
|
@ -25,7 +24,7 @@ class AddLastWorkfileToLaunchArgs(PreLaunchHook):
|
|||
"afftereffects"
|
||||
]
|
||||
|
||||
def execute(self):
|
||||
def get_last_workfile(self):
|
||||
if not self.data.get("start_last_workfile"):
|
||||
self.log.info("It is set to not start last workfile on start.")
|
||||
return
|
||||
|
|
@ -39,5 +38,38 @@ class AddLastWorkfileToLaunchArgs(PreLaunchHook):
|
|||
self.log.info("Current context does not have any workfile yet.")
|
||||
return
|
||||
|
||||
# Add path to workfile to arguments
|
||||
self.launch_context.launch_args.append(last_workfile)
|
||||
return last_workfile
|
||||
|
||||
def execute(self):
|
||||
|
||||
last_workfile = self.get_last_workfile()
|
||||
if last_workfile:
|
||||
# Add path to workfile to arguments
|
||||
self.launch_context.launch_args.append(last_workfile)
|
||||
|
||||
|
||||
class AddLastWorkfileToLaunchArgsHoudini(AddLastWorkfileToLaunchArgs):
|
||||
"""Add last workfile path to launch arguments - Houdini specific"""
|
||||
app_groups = ["houdini"]
|
||||
|
||||
def execute(self):
|
||||
|
||||
last_workfile = self.get_last_workfile()
|
||||
if last_workfile:
|
||||
# Whenever a filepath is passed to Houdini then the startup
|
||||
# scripts 123.py and houdinicore.py won't be triggered. Thus
|
||||
# OpenPype will not initialize correctly. As such, whenever
|
||||
# we pass a workfile we first explicitly pass a startup
|
||||
# script to enforce it to run - which will load the last passed
|
||||
# argument as workfile directly.
|
||||
pype_root = os.environ["OPENPYPE_REPOS_ROOT"]
|
||||
startup_path = os.path.join(
|
||||
pype_root, "openpype", "hosts", "houdini", "startup"
|
||||
)
|
||||
startup_script = os.path.join(startup_path,
|
||||
"scripts",
|
||||
"openpype_launch.py")
|
||||
self.launch_context.launch_args.append(startup_script)
|
||||
|
||||
# Add path to workfile to arguments
|
||||
self.launch_context.launch_args.append(last_workfile)
|
||||
|
|
|
|||
40
openpype/hosts/houdini/startup/scripts/openpype_launch.py
Normal file
40
openpype/hosts/houdini/startup/scripts/openpype_launch.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import os
|
||||
import sys
|
||||
import avalon.api
|
||||
from openpype.hosts.houdini import api
|
||||
import openpype.hosts.houdini.api.workio
|
||||
|
||||
import hou
|
||||
|
||||
|
||||
def is_workfile(path):
|
||||
if not path:
|
||||
return
|
||||
|
||||
if not os.path.exists(path):
|
||||
return False
|
||||
|
||||
_, ext = os.path.splitext(path)
|
||||
if ext in openpype.hosts.houdini.api.workio.file_extensions():
|
||||
return True
|
||||
|
||||
|
||||
def main():
|
||||
print("Installing OpenPype ...")
|
||||
avalon.api.install(api)
|
||||
|
||||
args = sys.argv
|
||||
if args and is_workfile(args[-1]):
|
||||
# If the last argument is a Houdini file open it directly
|
||||
workfile_path = args[-1].replace("\\", "/")
|
||||
print("Opening workfile on launch: {}".format(workfile_path))
|
||||
|
||||
# We don't use `workio.open_file` because we want to explicitly ignore
|
||||
# load warnings. Otherwise Houdini will fail to start if a scene load
|
||||
# produces e.g. errors on missing plug-ins
|
||||
hou.hipFile.load(workfile_path,
|
||||
suppress_save_prompt=True,
|
||||
ignore_load_warnings=True)
|
||||
|
||||
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue