import pfpym def pfMacroName(): return 'Process All' def main(tree): # an ordered list of nodes to be processed process= [] # a list of node types that require processing processable= ['Auto Match', 'Camera Solver'] # loop over every node # find ones which have no output # traverse up the tree from these noting all processable nodes for i in range(tree.getNumNodes()): node= tree.getNode(i) outputs= 0 for j in range(node.getNumOutputs()): outputs+= node.getNumOutputLinks(j) if outputs == 0: recurseUp(node, process, processable) # reverse list to get processing order # was bottom-to-top of tree, processing needs to be # done top-to-bottom process.reverse() # remove duplicates in list unique= [] for i in process: if i not in unique: unique.append(i) process= unique # process each node stage= 0 for i in process: tree.setBatchStage(stage, len(process)) # to accurately report % completion stage+= 1 node= tree.getNode(i) if node.getType() == 'Auto Match': node.autoMatch() elif node.getType() == 'Camera Solver': node.solveAll() def recurseUp(node, process, processable): # add to ordered list of nodes to process if node.getType() in processable: if not node.getLocked(): process.append(node.getID()) # loop over every input link recursing up through tree for i in range(node.getNumInputs()): for j in range(node.getNumInputLinks(i)): recurseUp(node.getInputLink(i, j).getFromNode(), process, processable)