mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
Fix mtoa errors on launch by loading deferred, cleanup id generation by moving logic into maya/lib.py
This commit is contained in:
parent
42860b5a2b
commit
50aaa96ecb
1 changed files with 17 additions and 34 deletions
|
|
@ -1,12 +1,13 @@
|
|||
import os
|
||||
import logging
|
||||
from functools import partial
|
||||
|
||||
from maya import utils
|
||||
from maya import cmds
|
||||
|
||||
from avalon import maya, io, api as avalon
|
||||
from avalon import api as avalon
|
||||
from pyblish import api as pyblish
|
||||
|
||||
|
||||
from . import menu
|
||||
from . import lib
|
||||
|
||||
|
|
@ -20,27 +21,16 @@ PUBLISH_PATH = os.path.join(PLUGINS_DIR, "maya", "publish")
|
|||
LOAD_PATH = os.path.join(PLUGINS_DIR, "maya", "load")
|
||||
CREATE_PATH = os.path.join(PLUGINS_DIR, "maya", "create")
|
||||
|
||||
LOAD_AT_START = ["AbcImport", "AbcExport", "mtoa"]
|
||||
|
||||
|
||||
def install():
|
||||
|
||||
pyblish.register_plugin_path(PUBLISH_PATH)
|
||||
avalon.register_plugin_path(avalon.Loader, LOAD_PATH)
|
||||
avalon.register_plugin_path(avalon.Creator, CREATE_PATH)
|
||||
|
||||
menu.install()
|
||||
|
||||
# Add any needed plugins
|
||||
for plugin in LOAD_AT_START:
|
||||
log.info("Loading %s" % plugin)
|
||||
if cmds.pluginInfo(plugin, query=True, loaded=True):
|
||||
continue
|
||||
cmds.loadPlugin(plugin, quiet=True)
|
||||
|
||||
log.info("Installing callbacks ... ")
|
||||
avalon.on("init", on_init)
|
||||
avalon.on("new", on_new)
|
||||
avalon.on("save", on_save)
|
||||
|
||||
|
||||
|
|
@ -55,19 +45,19 @@ def uninstall():
|
|||
def on_init(_):
|
||||
avalon.logger.info("Running callback on init..")
|
||||
|
||||
maya.commands.reset_frame_range()
|
||||
maya.commands.reset_resolution()
|
||||
def force_load_deferred(plugin):
|
||||
"""Load a plug-in deferred so it runs after UI has initialized"""
|
||||
try:
|
||||
utils.executeDeferred(partial(cmds.loadPlugin,
|
||||
plugin,
|
||||
quiet=True))
|
||||
except RuntimeError, e:
|
||||
log.warning("Can't load plug-in: "
|
||||
"{0} - {1}".format(plugin, e))
|
||||
|
||||
|
||||
def on_new(_):
|
||||
avalon.logger.info("Running callback on new..")
|
||||
|
||||
# Load dependencies
|
||||
cmds.loadPlugin("AbcExport.mll", quiet=True)
|
||||
cmds.loadPlugin("AbcImport.mll", quiet=True)
|
||||
|
||||
maya.commands.reset_frame_range()
|
||||
maya.commands.reset_resolution()
|
||||
# Set up all plug-ins
|
||||
for plugin in ["AbcImport", "AbcExport", "mtoa"]:
|
||||
force_load_deferred(plugin)
|
||||
|
||||
|
||||
def on_save(_):
|
||||
|
|
@ -78,13 +68,6 @@ def on_save(_):
|
|||
|
||||
avalon.logger.info("Running callback on save..")
|
||||
|
||||
# Generate ids of the current context on nodes in the scene
|
||||
nodes = lib.get_id_required_nodes(referenced_nodes=False)
|
||||
|
||||
# Lead with asset ID from the database
|
||||
asset = os.environ["AVALON_ASSET"]
|
||||
asset_id = io.find_one({"type": "asset", "name": asset},
|
||||
projection={"_id": True})
|
||||
|
||||
# generate the ids
|
||||
for node in nodes:
|
||||
lib.set_id(str(asset_id["_id"]), node)
|
||||
lib.generate_ids(nodes)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue