Beispiel #1
0
 def value(self, value):
     if not value and not isinstance(value, (int, float, bool, str)):
         return
     kwargs = {"setPortDefaultValues": [self.name, value]}
     if self.node.parent == "/" and not self.node.type:
         cmds.vnnCompound(self.board, self.node.parent, **kwargs)
         return
     node = self.node if self.node.type else self.node.parent
     cmds.vnnNode(self.board, str(node), **kwargs)
Beispiel #2
0
 def get_children(self):
     """Get children nodes."""
     try:
         nodes = cmds.vnnCompound(self.board, self, listNodes=True)
         return [self.node(x) for x in nodes]
     except RuntimeError:
         return []
Beispiel #3
0
    def rename(self, name):
        """Rename node.

        Note:
            the `renameNode` option doesn't return the new name, so the
            only way to figure out the unique name is to query all nodes,
            rename, query again and diff...(cool stuff, right?!)
        """
        if not name or self.name == name:
            return None

        all_nodes = cmds.vnnCompound(self.board, self.parent, listNodes=True)
        cmds.vnnCompound(self.board, self.parent, renameNode=[self.name, name])
        new_nodes = cmds.vnnCompound(self.board, self.parent, listNodes=True)
        node = list(set(new_nodes) - set(all_nodes))[0]

        self.path = self.parent + node
        return self.path
Beispiel #4
0
    def _create(self, nodetype, name=None):
        """Create a bifrost node in the current graph."""
        path = self.path
        if nodetype == "compound":
            node = cmds.vnnCompound(self.board, path, create="compound")
            self.is_compound = True
        else:
            nodetype = self._fix_type(nodetype)
            type_ = self.board + "," + nodetype
            separator = "" if path.endswith("/") else "/"
            node = cmds.vnnCompound(self.board, path, addNode=type_)[0]
            node = "{}{}{}".format(path, separator, node)

        if not node:
            msg = "Can't create node '{}' (Type: '{}')".format(path, nodetype)
            raise RuntimeError(msg)

        self.path = node
        self.set_metadata(["UUID", str(uuid.uuid4()).upper()])
        self.rename(name)
Beispiel #5
0
 def nodes(self):
     """Get nodes at the board/root level."""
     children = cmds.vnnCompound(self.board, "/", listNodes=True) or []
     return [self.get(x) for x in children]