def repair(cls, instance): for node in cls.get_invalid(instance): # Get the original id from history history_id = lib.get_id_from_history(node) if not history_id: cls.log.error("Could not find ID in history for '%s'", node) continue lib.set_id(node, history_id, overwrite=True)
def _update_id_attribute(self, instance, nodes): """Delete the id attribute Args: instance: The instance we're fixing for nodes (list): all nodes to regenerate ids on """ from pype.hosts.maya.api import lib import avalon.io as io asset = instance.data['asset'] asset_id = io.find_one({ "name": asset, "type": "asset" }, projection={"_id": True})['_id'] for node, _id in lib.generate_ids(nodes, asset_id=asset_id): lib.set_id(node, _id, overwrite=True)
def create_nodes(self, namespace, settings): """Create nodes with the correct namespace and settings Args: namespace(str): namespace settings(list): list of dictionaries Returns: list """ nodes = [] for node_settings in settings: # Create pgYetiMaya node original_node = node_settings["name"] node_name = "{}:{}".format(namespace, original_node) yeti_node = cmds.createNode("pgYetiMaya", name=node_name) # Create transform node transform_node = node_name.rstrip("Shape") lib.set_id(transform_node, node_settings["transform"]["cbId"]) lib.set_id(yeti_node, node_settings["cbId"]) nodes.extend([transform_node, yeti_node]) # Ensure the node has no namespace identifiers attributes = node_settings["attrs"] # Check if cache file name is stored # get number of # in path and convert it to C prinf format # like %04d expected by Yeti fbase = re.search(r'^(.+)\.(\d+|#+)\.fur', self.fname) if not fbase: raise RuntimeError('Cannot determine file path') padding = len(fbase.group(2)) if "cacheFileName" not in attributes: cache = "{}.%0{}d.fur".format(fbase.group(1), padding) self.validate_cache(cache) attributes["cacheFileName"] = cache # Update attributes with requirements attributes.update({ "viewportDensity": 0.1, "verbosity": 2, "fileMode": 1 }) # Apply attributes to pgYetiMaya node for attr, value in attributes.items(): if value is None: continue lib.set_attribute(attr, value, yeti_node) # Fix for : YETI-6 # Fixes the render stats (this is literally taken from Perigrene's # ../scripts/pgYetiNode.mel script) cmds.setAttr("{}.visibleInReflections".format(yeti_node), True) cmds.setAttr("{}.visibleInRefractions".format(yeti_node), True) # Connect to the time node cmds.connectAttr("time1.outTime", "%s.currentTime" % yeti_node) return nodes