예제 #1
0
def on_open(_):
    sticker.reveal()  # Show custom icon

    cmds.evalDeferred("from reveries.maya import callbacks;"
                      "callbacks._outliner_hide_set_member()")

    # (Medicine)
    #
    maya_utils.drop_interface()
    # Only fix containerized file nodes
    nodes = set()
    for container in maya.ls():
        nodes.update(
            cmds.ls(cmds.sets(container["objectName"], query=True),
                    type="file"))
    maya_utils.fix_texture_file_nodes(list(nodes))

    if cmds.about(batch=True):
        # For log reading and debug
        print("Maya API version: %s" % cmds.about(api=True))
        if cmds.pluginInfo("mtoa", q=True, loaded=True):
            version = cmds.pluginInfo("mtoa", q=True, version=True)
            print("MtoA version: %s" % version)
    else:
        if lib.any_outdated():
            _pop_sceneinventory()
예제 #2
0
def test_update():
    """Updating works"""

    transform, generator = cmds.polyCube(name="body_PLY")
    group = cmds.group(transform, name="ROOT")

    cmds.select(group, replace=True)
    maya.create(name="modelDefault",
                asset=ASSET_NAME,
                family="mindbender.model",
                options={"useSelection": True})

    # Comply with save validator
    cmds.file(save=True)

    publish()
    publish()
    publish()  # Version 3

    cmds.file(new=True, force=True)

    asset = io.find_one({"type": "asset", "name": ASSET_NAME})

    subset = io.find_one({
        "parent": asset["_id"],
        "type": "subset",
        "name": "modelDefault"
    })

    version = io.find_one({
        "parent": subset["_id"],
        "type": "version",
        "name": 2
    })

    assert version

    representation = io.find_one({
        "parent": version["_id"],
        "type": "representation",
        "name": "ma"
    })

    maya.load(representation["_id"])
    container = next(maya.ls())
    maya.update(container, 3)
예제 #3
0
    def process(self, instance):

        # Find containers
        containers = avalon.ls()

        # Get all content from the instance
        instance_lookup = set(cmds.ls(instance, type="transform", long=True))
        data = defaultdict(list)
        self.log.info(instance_lookup)

        hierarchy_nodes = []
        for container in containers:

            self.log.info(container)
            root = lib.get_container_transforms(container, root=True)
            self.log.info(root)
            if not root or root not in instance_lookup:
                continue

            # Retrieve the hierarchy
            parent = cmds.listRelatives(root, parent=True, fullPath=True)[0]
            hierarchy_nodes.append(parent)

            # Temporary warning for GPU cache which are not supported yet
            loader = container["loader"]
            if loader == "GpuCacheLoader":
                self.log.warning("GPU Cache Loader is currently not supported"
                                 "in the pipeline, we will export it tho")

            # Gather info for new data entry
            representation_id = container["representation"]
            instance_data = {
                "loader": loader,
                "parent": parent,
                "namespace": container["namespace"]
            }

            # Check if matrix differs from default and store changes
            matrix_data = self.get_matrix_data(root)
            if matrix_data:
                instance_data["matrix"] = matrix_data

            data[representation_id].append(instance_data)

        instance.data["scenedata"] = dict(data)
        instance.data["hierarchy"] = list(set(hierarchy_nodes))