mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 17:04:54 +01:00
add open template for maya
This commit is contained in:
parent
d87f217fb9
commit
7c705eded6
2 changed files with 54 additions and 10 deletions
|
|
@ -19,6 +19,7 @@ from .workfile_template_builder import (
|
|||
update_placeholder,
|
||||
build_workfile_template,
|
||||
update_workfile_template,
|
||||
open_template,
|
||||
)
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
|
@ -158,16 +159,6 @@ def install():
|
|||
tearOff=True,
|
||||
parent=MENU_NAME
|
||||
)
|
||||
cmds.menuItem(
|
||||
"Create Placeholder",
|
||||
parent=builder_menu,
|
||||
command=create_placeholder
|
||||
)
|
||||
cmds.menuItem(
|
||||
"Update Placeholder",
|
||||
parent=builder_menu,
|
||||
command=update_placeholder
|
||||
)
|
||||
cmds.menuItem(
|
||||
"Build Workfile from template",
|
||||
parent=builder_menu,
|
||||
|
|
@ -178,6 +169,25 @@ def install():
|
|||
parent=builder_menu,
|
||||
command=update_workfile_template
|
||||
)
|
||||
cmds.menuItem(
|
||||
divider=True,
|
||||
parent=builder_menu
|
||||
)
|
||||
cmds.menuItem(
|
||||
"Open Template",
|
||||
parent=builder_menu,
|
||||
command=open_template,
|
||||
)
|
||||
cmds.menuItem(
|
||||
"Create Placeholder",
|
||||
parent=builder_menu,
|
||||
command=create_placeholder
|
||||
)
|
||||
cmds.menuItem(
|
||||
"Update Placeholder",
|
||||
parent=builder_menu,
|
||||
command=update_placeholder
|
||||
)
|
||||
|
||||
cmds.setParent(MENU_NAME, menu=True)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import json
|
||||
import os
|
||||
|
||||
from maya import cmds
|
||||
|
||||
|
|
@ -24,6 +25,36 @@ class MayaTemplateBuilder(AbstractTemplateBuilder):
|
|||
|
||||
use_legacy_creators = True
|
||||
|
||||
def open_template(self):
|
||||
"""Open template in current scene.
|
||||
"""
|
||||
template_preset = self.get_template_preset()
|
||||
template_path = template_preset["path"]
|
||||
|
||||
if not os.path.exists(template_path):
|
||||
cmds.confirmDialog(
|
||||
title="Warning",
|
||||
message="Template doesn't exist: {}".format(template_path),
|
||||
button=["OK"],
|
||||
defaultButton="OK",
|
||||
)
|
||||
return
|
||||
|
||||
result = cmds.confirmDialog(
|
||||
title="Warning",
|
||||
message="Opening a template will clear the current scene.",
|
||||
button=["OK", "Cancel"],
|
||||
defaultButton="OK",
|
||||
cancelButton="Cancel",
|
||||
dismissString="Cancel",
|
||||
)
|
||||
|
||||
if result != "OK":
|
||||
return
|
||||
|
||||
print("opening template {}".format(template_path))
|
||||
cmds.file(template_path, open=True, force=True)
|
||||
|
||||
def import_template(self, path):
|
||||
"""Import template into current scene.
|
||||
Block if a template is already loaded.
|
||||
|
|
@ -298,6 +329,9 @@ def update_workfile_template(*args):
|
|||
builder = MayaTemplateBuilder(registered_host())
|
||||
builder.rebuild_template()
|
||||
|
||||
def open_template(*args):
|
||||
builder = MayaTemplateBuilder(registered_host())
|
||||
builder.open_template()
|
||||
|
||||
def create_placeholder(*args):
|
||||
host = registered_host()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue