diff --git a/openpype/hosts/maya/api/__init__.py b/openpype/hosts/maya/api/__init__.py index 9219da407f..1c8534d9a5 100644 --- a/openpype/hosts/maya/api/__init__.py +++ b/openpype/hosts/maya/api/__init__.py @@ -35,6 +35,7 @@ def install(): pyblish.register_plugin_path(PUBLISH_PATH) avalon.register_plugin_path(avalon.Loader, LOAD_PATH) avalon.register_plugin_path(avalon.Creator, CREATE_PATH) + avalon.register_plugin_path(avalon.InventoryAction, INVENTORY_PATH) log.info(PUBLISH_PATH) menu.install() diff --git a/openpype/hosts/maya/plugins/inventory/import_reference.py b/openpype/hosts/maya/plugins/inventory/import_reference.py new file mode 100644 index 0000000000..d389c8733e --- /dev/null +++ b/openpype/hosts/maya/plugins/inventory/import_reference.py @@ -0,0 +1,27 @@ +from maya import cmds + +from avalon import api + + +class ImportReference(api.InventoryAction): + """Imports selected reference inside the file.""" + + label = "Import Reference" + icon = "mouse-pointer" + color = "#d8d8d8" + + def process(self, containers): + references = cmds.ls(type="reference") + + for container in containers: + if container["loader"] != "ReferenceLoader": + print("Not a reference, skipping") + continue + + reference_name = container["namespace"] + "RN" + if reference_name in references: + print("Importing {}".format(reference_name)) + + ref_file = cmds.referenceQuery(reference_name, f=True) + + cmds.file(ref_file, importReference=True)