def collapseNodes(nodes, collapsedNode=None): parentNode = _checkNodesShareSameParent(nodes) if collapsedNode is None: collapsedNode = coralApp.createNode( CollapserData.collapsedNodeClassName, CollapserData.collapsedNodeClassName, parentNode) inPassAttrs = {} outPassAttrs = {} for node in nodes: disconnectedAttributes = _disconnectConnectedInputs(node, nodes) inputAttributes = disconnectedAttributes[0] inputAttributesWithOutputConnections = disconnectedAttributes[1] outputAttributes = _disconnectConnectedOutputs(node, nodes) parentNode.removeNode(node) collapsedNode.addNode(node) for attr in inputAttributes: sourceAttr = attr[0] destAttr = attr[1] passAttrName = sourceAttr.parent().name() + "_" + sourceAttr.name() if inPassAttrs.has_key(passAttrName) == False: passAttr = coralApp.createAttribute("PassThroughAttribute", "input", collapsedNode, input=True) NetworkManager.connect(sourceAttr, passAttr) inPassAttrs[passAttrName] = passAttr else: passAttr = inPassAttrs[passAttrName] NetworkManager.connect(passAttr, destAttr) for attr in outputAttributes: sourceAttr = attr[0] destAttr = attr[1] passAttrName = sourceAttr.parent().name() + "_" + sourceAttr.name() if outPassAttrs.has_key(passAttrName) == False: passAttr = coralApp.createAttribute("PassThroughAttribute", "output", collapsedNode, output=True) NetworkManager.connect(sourceAttr, passAttr) outPassAttrs[passAttrName] = passAttr else: passAttr = outPassAttrs[passAttrName] NetworkManager.connect(passAttr, destAttr) return collapsedNode
def collapseNodes(nodes, collapsedNode = None): parentNode = _checkNodesShareSameParent(nodes) if collapsedNode is None: collapsedNode = coralApp.createNode(CollapserData.collapsedNodeClassName, CollapserData.collapsedNodeClassName, parentNode) inPassAttrs = {} outPassAttrs = {} for node in nodes: disconnectedAttributes = _disconnectConnectedInputs(node, nodes) inputAttributes = disconnectedAttributes[0] inputAttributesWithOutputConnections = disconnectedAttributes[1] outputAttributes = _disconnectConnectedOutputs(node, nodes) parentNode.removeNode(node) collapsedNode.addNode(node) for attr in inputAttributes: sourceAttr = attr[0] destAttr = attr[1] passAttrName = sourceAttr.parent().name() + "_" + sourceAttr.name() if inPassAttrs.has_key(passAttrName) == False: passAttr = coralApp.createAttribute("PassThroughAttribute", "input", collapsedNode, input = True) NetworkManager.connect(sourceAttr, passAttr) inPassAttrs[passAttrName] = passAttr else: passAttr = inPassAttrs[passAttrName] NetworkManager.connect(passAttr, destAttr) for attr in outputAttributes: sourceAttr = attr[0] destAttr = attr[1] passAttrName = sourceAttr.parent().name() + "_" + sourceAttr.name() if outPassAttrs.has_key(passAttrName) == False: passAttr = coralApp.createAttribute("PassThroughAttribute", "output", collapsedNode, output = True) NetworkManager.connect(sourceAttr, passAttr) outPassAttrs[passAttrName] = passAttr else: passAttr = outPassAttrs[passAttrName] NetworkManager.connect(passAttr, destAttr) return collapsedNode
def doIt(self): className = self.argAsString("className") name = self.argAsString("name") parentNode = self.argAsString("parentNode") newNode = None parentNode = coralApp.findNode(parentNode) if parentNode: newNode = coralApp.createNode(className, name, parentNode) if newNode: specializationPreset = self.argAsString("specializationPreset") if specializationPreset: newNode.enableSpecializationPreset(specializationPreset) self.setResultString(newNode.fullName()) if newNode is None: coralApp.logDebug("CreateNode Command: failed to create new node.")