Skip to content

import_reference

ImportReference

Bases: InventoryAction

Imports selected reference to inside of the file.

Source code in client/ayon_maya/plugins/inventory/import_reference.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class ImportReference(InventoryAction):
    """Imports selected reference to inside of the file."""

    label = "Import Reference"
    icon = "download"
    color = "#d8d8d8"

    supported_loaders = {"ReferenceLoader", "MayaUSDReferenceLoader"}

    def process(self, containers):
        for container in containers:
            if container["loader"] not in self.supported_loaders:
                print("Not a reference, skipping")
                continue

            node = container["objectName"]
            members = cmds.sets(node, query=True, nodesOnly=True)
            ref_node = get_reference_node(members)

            ref_file = cmds.referenceQuery(ref_node, f=True)
            cmds.file(ref_file, importReference=True)

        return True  # return anything to trigger model refresh

    @classmethod
    def is_compatible(cls, container):
        return container.get("loader") in cls.supported_loaders