diff --git a/colorbleed/plugins/maya/load/actions.py b/colorbleed/plugins/maya/load/actions.py index 7b63c7d194..12a3dfe248 100644 --- a/colorbleed/plugins/maya/load/actions.py +++ b/colorbleed/plugins/maya/load/actions.py @@ -76,3 +76,46 @@ class SetFrameRangeWithHandlesLoader(api.Loader): maxTime=end, animationStartTime=start, animationEndTime=end) + + +class ImportMayaLoader(api.Loader): + """Import action for Maya (unmanaged) + + Warning: + The loaded content will be unmanaged and is *not* visible in the + scene inventory. It's purely intended to merge content into your scene + so you could also use it as a new base. + + """ + representations = ["ma"] + families = ["*"] + + label = "Import" + order = 10 + icon = "arrow-circle-down" + color = "#775555" + + def load(self, context, name=None, namespace=None, data=None): + import maya.cmds as cmds + + from avalon import maya + from avalon.maya import lib + + asset = context['asset'] + + namespace = namespace or lib.unique_namespace( + asset["name"] + "_", + prefix="_" if asset["name"][0].isdigit() else "", + suffix="_", + ) + + with maya.maintained_selection(): + cmds.file(self.fname, + i=True, + namespace=namespace, + returnNewNodes=True, + groupReference=True, + groupName="{}:{}".format(namespace, name)) + + # We do not containerize imported content, it remains unmanaged + return diff --git a/colorbleed/plugins/maya/load/load_model.py b/colorbleed/plugins/maya/load/load_model.py index eb76bd9ada..0d08c6ecbd 100644 --- a/colorbleed/plugins/maya/load/load_model.py +++ b/colorbleed/plugins/maya/load/load_model.py @@ -34,101 +34,6 @@ class ModelLoader(colorbleed.maya.plugin.ReferenceLoader): self.update(container, representation) -class ImportModelLoader(api.Loader): - """An ImportModelLoader for Maya - - This will implement the basic behavior for a loader to inherit from that - will containerize content. The loader will not be able to use `update` - but only `remove`. When calling the `update` the loader will return a - "NotImplementedError". - - """ - - families = ["colorbleed.model"] - representations = ["ma"] - - label = "Import Model" - order = 10 - icon = "arrow-circle-down" - color = "white" - - def load(self, context, name=None, namespace=None, data=None): - - import maya.cmds as cmds - - from avalon import maya - from avalon.maya import lib - from avalon.maya.pipeline import containerise - - asset = context['asset'] - - namespace = namespace or lib.unique_namespace( - asset["name"] + "_", - prefix="_" if asset["name"][0].isdigit() else "", - suffix="_", - ) - - with maya.maintained_selection(): - nodes = cmds.file(self.fname, - i=True, - namespace=namespace, - returnNewNodes=True, - groupReference=True, - groupName="{}:{}".format(namespace, name)) - - # Only containerize if any nodes were loaded by the Loader - if not nodes: - return - - self[:] = nodes - - return containerise( - name=name, - namespace=namespace, - nodes=nodes, - context=context, - loader=self.__class__.__name__) - - def update(self, container, representation): - from avalon.vendor.Qt import QtWidgets - - message = ("The content of this asset was imported. " - "We cannot update this because we will need" - " to keep insane amount of things in mind.\n" - "Please remove and reimport the asset." - "\n\nIf you really need to update a lot we " - "recommend referencing.") - - QtWidgets.QMessageBox.critical(None, - "Can't update", - message, - QtWidgets.QMessageBox.Ok) - - return - - def remove(self, container): - - from maya import cmds - - namespace = container["namespace"] - container_name = container["objectName"] - - self.log.info("Removing '%s' from Maya.." % container["name"]) - - container_content = cmds.sets(container_name, query=True) - nodes = cmds.ls(container_content, long=True) - - nodes.append(container_name) - - try: - cmds.delete(nodes) - except ValueError: - # Already implicitly deleted by Maya upon removing reference - pass - - cmds.namespace(removeNamespace=namespace, deleteNamespaceContent=True) - - class GpuCacheLoader(api.Loader): """Load model Alembic as gpuCache"""