def setUpClass(cls): '''Procedurally create nodes for testing.''' # Add a PxrUsdIn node and set its motion sample times pxrUsdInNode = NodegraphAPI.CreateNode('PxrUsdIn', NodegraphAPI.GetRootNode()) pxrUsdInNode.getParameter('motionSampleTimes').setValue('0 -1', 0) # Add a RenderSettings node and turn on motion blur renderSettingsNode = NodegraphAPI.CreateNode( 'RenderSettings', NodegraphAPI.GetRootNode()) mts = renderSettingsNode.getParameter( 'args.renderSettings.maxTimeSamples') mts.getChild('value').setValue(2, 0) mts.getChild('enable').setValue(1, 0) sc = renderSettingsNode.getParameter( 'args.renderSettings.shutterClose') sc.getChild('value').setValue(0.5, 0) sc.getChild('enable').setValue(1, 0) # Connect the two nodes together and view from the RS node pxrUsdInNode.getOutputPortByIndex(0).connect( renderSettingsNode.getInputPortByIndex(0)) NodegraphAPI.SetNodeViewed(renderSettingsNode, True, True) # Set the current frame NodegraphAPI.SetCurrentTime(50)
def ActionCallback(value): RenderNode = NodegraphAPI.GetNode(str(value)) NodegraphAPI.SetNodeViewed(RenderNode, viewed=True, exclusive=True) if UI4.App.Tabs.FindTopTab('Monitor'): RenderManager.StartRender('previewRender', node=RenderNode) else: pass
def create_node(): ''' :description to create lookdev bake node :param None :example from resources.studio_nodes.lookdev_bake_node import node node.create_node() ''' parent = NodegraphAPI.GetRootNode() knode = NodegraphAPI.CreateNode('LookFileBake', parent=parent) knode.setName(studio_nodes.LOOKDEV_BAKE_NODE_TYPE) add_parameters(knode) NodegraphAPI.SetNodeViewed(knode, True, exclusive=True) NodegraphAPI.SetNodeEdited(knode, True, exclusive=True)
def create_node(): ''' :description to create generic asset node :param None :example from resources.studio_nodes.generic_asset_node import node node.create_node() ''' parent = NodegraphAPI.GetRootNode() knode = NodegraphAPI.CreateNode('Group', parent=parent) knode.setName(studio_nodes.GENERIC_ASSET_NODE_TYPE) add_parameters(knode) NodegraphAPI.SetNodeViewed(knode, True, exclusive=True) NodegraphAPI.SetNodeEdited(knode, True, exclusive=True)
def get_producer(knode, location=None): ''' :description get the scenegraph location producer :prama knode <Nodegraph Node Object> :param location <str> :example from core import scenegraph knode = NodegraphAPI.GetAllSelectedNodes()[0] scenegraph.get_producer(knode, location=None) ''' NodegraphAPI.SetNodeViewed(knode, True, exclusive=True) producer = Nodes3DAPI.GetGeometryProducer(node=knode) if location: producer = producer.getProducerByPath(location) return producer
def create_node(): ''' :description to create lighting asset node :param None :example from resources.studio_nodes.lighting_asset_node import node node.create_node() ''' parent = NodegraphAPI.GetRootNode() knode = NodegraphAPI.CreateNode('Group', parent=parent) knode.setName(studio_nodes.LIGHTING_ASSET_NODE_TYPE) knode.addOutputPort('out') add_parameters(knode) NodegraphAPI.SetNodeViewed(knode, True, exclusive=True) NodegraphAPI.SetNodeEdited(knode, True, exclusive=True)
def createKatanaNodes(fileOut = '/tmp/fileDispFromLua.txt'): # check if there is a node ('Attribute_Disp') existing if yes delete it # existingNode = NodegraphAPI.GetNode('Attribute_Disp') # if existingNode : # inputNodePort = existingNode.getInputPortByIndex(0) # outputNodePort = existingNode.getOutputPortByIndex(0) # inputNodePort.connect(outputNodePort) # existingNode.delete() inputFile = open(fileOut,'a') node = NodegraphAPI.GetAllSelectedNodes()[0] # select the node nodePos = NodegraphAPI.GetNodePosition(node) # get the position of node nodeOutPort = node.getOutputPortByIndex(0) # get the output port nextPort = nodeOutPort.getConnectedPorts()[0] # get the first connected port from the previous node # create the opscript node root = NodegraphAPI.GetRootNode() opscriptFindDisp = NodegraphAPI.CreateNode('OpScript',root) opscriptFindDisp.setName('findDisp') opscriptFindDisp.getParameter('CEL').setValue('/root/world//*{hasattr("materialOverride.parameters.dsp_map")}',0) opscriptFindDispUserParam = opscriptFindDisp.getParameters().createChildGroup('user') opscriptFindDispUserParamFileOut = opscriptFindDispUserParam.createChildString('fileOut',fileOut) opscriptFindDisp.getParameter('script.lua').setValue("local getdispMap = require 'dispFunc'\ngetdispMap.getDispMap()",0) opscriptFindDispInPort = opscriptFindDisp.getInputPort('i0') opscriptFindDispOutPort = opscriptFindDisp.getOutputPort('out') nodeOutPort.connect(opscriptFindDispInPort) opscriptFindDispOutPort.connect(nextPort) NodegraphAPI.SetNodePosition(opscriptFindDisp, (nodePos[0]+50,nodePos[1]-50)) opscriptFindDispPos = NodegraphAPI.GetNodePosition(opscriptFindDisp) # set the view and the edit on the opscript node NodegraphAPI.SetNodeViewed(opscriptFindDisp, True, exclusive=True) NodegraphAPI.SetNodeEdited(opscriptFindDisp, True, exclusive=True) # dummy functions to run the opscript and create the file sg = ScenegraphManager.getActiveScenegraph() node = NodegraphAPI.GetNode( 'root' ) time = NodegraphAPI.GetCurrentTime() producer = Nodes3DAPI.GetGeometryProducer( node, time) prod = producer.getProducerByPath('/root') WalkBoundAttrLocations(prod) # extract the dip for each map assetWithDisp = findDispHeight(fileOut) # create a stack of AttributeSet to set the disp if there is element in the dict if len(assetWithDisp.keys()): stack = NodegraphAPI.CreateNode("GroupStack", NodegraphAPI.GetRootNode()) stack.setName('Attribute_Disp') stack.setChildNodeType("AttributeSet") listWord = ['/location/','/prop/','/location/','/character/'] for key in assetWithDisp.keys(): path = '' attributSet = stack.buildChildNode() attributSet.getParameter('mode').setValue('CEL',0) attrPath = attributSet.getParameter('celSelection') attributSet.getParameter('attributeType').setValue('float',0) # replace the word from listWord by the wildcard '/*' so to work in lighting scene for word in listWord: if key.find(word) > 1: path = key.replace(word,'//*/') attrPath.setValue(path,0) break else: attrPath.setValue(key,0) attributSet.setName(key[key.rfind('/')+1:]) # set name to the _hi attrValue = attributSet.getParameter('numberValue.i0') attrValue.setValue(assetWithDisp[key],0) attrName = attributSet.getParameter('attributeName') attrName.setValue('arnoldStatements.disp_padding',0) NodegraphAPI.SetNodePosition(stack,opscriptFindDispPos) stackInPort = stack.getInputPort('in') stackOutPort = stack.getOutputPort('out') nodeOutPort.connect(stackInPort) stackOutPort.connect(nextPort) NodegraphAPI.SetNodeViewed(stack, True, exclusive=True) NodegraphAPI.SetNodeEdited(stack, True, exclusive=True) else: # reconnect the nodes nodeOutPort.connect(nextPort) NodegraphAPI.SetNodeViewed(node, True, exclusive=True) NodegraphAPI.SetNodeEdited(node, True, exclusive=True) # delete the opscript and the file opscriptFindDisp.delete() os.remove(fileOut) print 'finished'
def viewNode(): NodegraphAPI.SetNodeViewed( scriptItem.getRenderNode(), True, exclusive=True)
def viewNode(): NodegraphAPI.SetNodeViewed( scriptItem.getShadowBranchNode(), True, exclusive=True)