Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to run the workfile template builder on startup and simplify resolve houdini path #74

Merged
merged 8 commits into from
Sep 10, 2024
15 changes: 15 additions & 0 deletions client/ayon_houdini/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
from ayon_core.pipeline.create import CreateContext
from ayon_core.pipeline.template_data import get_template_data
from ayon_core.pipeline.context_tools import get_current_task_entity
from ayon_core.pipeline.workfile.workfile_template_builder import (
TemplateProfileNotFound
)
from ayon_core.tools.utils import PopupUpdateKeys, SimplePopup
from ayon_core.tools.utils.host_tools import get_tool_by_name

Expand Down Expand Up @@ -1389,3 +1392,15 @@ def prompt_reset_context():
update_content_on_context_change()

dialog.deleteLater()


def start_workfile_template_builder():
from .workfile_template_builder import (
build_workfile_template
)

log.info("Starting workfile template builder...")
BigRoy marked this conversation as resolved.
Show resolved Hide resolved
try:
build_workfile_template(workfile_creation_enabled=True)
except TemplateProfileNotFound:
log.warning("Template profile not found. Skipping...")
6 changes: 6 additions & 0 deletions client/ayon_houdini/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ def install(self):
# opening with last workfile.
_set_context_settings()

# Manually call on_new callback as it doesn't get called when AYON
# launches for the first time on a context, only when going to
# File -> New
on_new()
BigRoy marked this conversation as resolved.
Show resolved Hide resolved

if not IS_HEADLESS:
import hdefereval # noqa, hdefereval is only available in ui mode
# Defer generation of shelves due to issue on Windows where shelf
Expand Down Expand Up @@ -414,6 +419,7 @@ def _enforce_start_frame():

if hou.isUIAvailable():
import hdefereval
hdefereval.executeDeferred(lib.start_workfile_template_builder)
hdefereval.executeDeferred(_enforce_start_frame)
else:
# Run without execute deferred when no UI is available because
Expand Down
4 changes: 2 additions & 2 deletions client/ayon_houdini/api/workfile_template_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ def delete_placeholder(self, placeholder):
placeholder_node.destroy()


def build_workfile_template(*args):
def build_workfile_template(*args, **kwargs):
# NOTE Should we inform users that they'll lose unsaved changes ?
builder = HoudiniTemplateBuilder(registered_host())
builder.build_template()
builder.build_template(*args, **kwargs)


def update_workfile_template(*args):
Expand Down