Example #1
0
def createMasterBlocker(name='BlockerGroup',
                        parent=NodegraphAPI.GetRootNode()):
    rootNode = parent
    #create the groupNode
    groupNode = NodegraphAPI.CreateNode('Group', rootNode)
    groupNode.setName(name)
    #add in and out port
    groupNode.addInputPort('in')
    groupNode.addOutputPort('out')
    #add attribute to switch the display of group node to normal node
    groupNodeAttrDict = {'ns_basicDisplay': 1, 'ns_iconName': ''}
    groupNode.setAttributes(groupNodeAttrDict)
    blockerName = 'Blocker1'

    #create a first blocker
    blocker = createSingleBlocker(groupNode, 'getParent().getParent().', False)
    paramui(groupNode, blocker.getName(), True)

    #reorder the button addBlocker to be the last param
    blockerParam = groupNode.getParameters()
    paramAddBlocker = blockerParam.getChild('addBlocker')
    numberOfChild = blockerParam.getNumChildren() - 1
    blockerParam.reorderChild(paramAddBlocker, numberOfChild)

    #create a dot node
    dotNode = NodegraphAPI.CreateNode('Dot', groupNode)
    dotNode.setName('outDot')

    #connection
    sendGroup = groupNode.getSendPort('in')
    returnGroup = groupNode.getReturnPort('out')
    blocker.getInputPort('in').connect(sendGroup)
    blocker.getOutputPort('out').connect(dotNode.getInputPort('input'))
    dotNode.getOutputPort('output').connect(returnGroup)

    #set position of nodes
    centralPos = NodegraphAPI.GetNodePosition(blocker)
    NodegraphAPI.SetNodePosition(dotNode, (centralPos[0], centralPos[1] - 50))

    #put the node under the mouse
    currentSelection = NodegraphAPI.GetAllSelectedNodes()
    for node in currentSelection:
        NodegraphAPI.SetNodeSelected(node, False)
    NodegraphAPI.SetNodeSelected(groupNode, True)
    # Get list of selected nodes
    nodeList = NodegraphAPI.GetAllSelectedNodes()
    # Find Nodegraph tab and float nodes
    nodegraphTab = UI4.App.Tabs.FindTopTab('Node Graph')
    if nodegraphTab:
        nodegraphTab.floatNodes(nodeList)
Example #2
0
def createMasterSample(name='SampleGroup',parent = NodegraphAPI.GetRootNode()):
    rootNode = parent
    #create the groupNode
    groupNode = NodegraphAPI.CreateNode('Group',rootNode)
    groupNode.setName(name)
    #add in and out port
    groupNode.addInputPort('in')
    groupNode.addOutputPort('out')
    #add attribute to switch the display of group node to normal node
    groupNodeAttrDict = {'ns_basicDisplay': 1,'ns_iconName': ''}
    groupNode.setAttributes(groupNodeAttrDict)
    blockerName = 'Blocker1'

    addButton =groupNode.getParameters().createChildString('addSampleNode','add sample node')
    addButton.setHintString("{'widget': 'scriptButton', 'buttonText': 'add Sample Node', 'scriptText': \"from sampleGroupCreate import displayLineUI\\n"
                                    "a=displayLineUI(node)\\na.show()\", 'help': 'add a new sample block to the group'}")

    #create a dot node
    dotOutNode = NodegraphAPI.CreateNode('Dot',groupNode)
    dotOutNode.setName('outDot')

    #connection
    sendGroup = groupNode.getSendPort('in')
    returnGroup = groupNode.getReturnPort('out')
    dotOutNode.getInputPort('input').connect(sendGroup)
    dotOutNode.getOutputPort('output').connect(returnGroup)

    #put the node under the mouse
    currentSelection = NodegraphAPI.GetAllSelectedNodes()
    for node in currentSelection:
        NodegraphAPI.SetNodeSelected(node,False)
    NodegraphAPI.SetNodeSelected(groupNode,True)
    # Get list of selected nodes
    nodeList = NodegraphAPI.GetAllSelectedNodes()
    # Find Nodegraph tab and float nodes
    nodegraphTab = UI4.App.Tabs.FindTopTab('Node Graph')
    if nodegraphTab:
        nodegraphTab.floatNodes(nodeList)
Example #3
0
 def displayOpenDialog(self):
     fname = str(
         QFileDialog.getOpenFileName(self, 'Open file',
                                     '/s/prodanim/asterix2',
                                     "Katana files (*.katana)"))
     if fname == '':
         print 'No file has been open'
     if self.sender().objectName() == 'openAction':
         KatanaFile.Load(fname)
         print 'Loading : ' + fname
     else:
         currentSelection = NodegraphAPI.GetAllSelectedNodes()
         #deselect all the node to select only the 2 created nodes and put them floating under the mouse
         for node in currentSelection:
             NodegraphAPI.SetNodeSelected(node, False)
         KatanaFile.Import(fname, floatNodes=True)
         print 'importing : ' + fname
         nodeList = NodegraphAPI.GetAllSelectedNodes()
         # Find Nodegraph tab and float nodes
         nodegraphTab = Tabs.FindTopTab('Node Graph')
         if nodegraphTab:
             nodegraphTab.floatNodes(nodeList)
Example #4
0
def createNode(node_type_string, auto_position=True):
    ''' create a type of node, and put that node in the center of the current focused group'''
    # get node graph widget
    ngw = getNodeGraphView()
    root = NodegraphAPI.GetRootNode()
    focused_node = getCurrentFocuseNode()
    if not focused_node:
        focused_node = root
    new_node = NodegraphAPI.CreateNode(node_type_string, focused_node)
    if auto_position:
        # view port center position in root node space
        # returned value lik ((815.5, -279.0, 10000.0), (1.0, 1.0, 1.0))
        center = NodegraphAPI.GetViewPortPosition(root)
        # convert to group position
        pos = ngw.getPointAdjustedToGroupNodeSpace(
            focused_node, (center[0][0], center[0][1]))
        # put the node at the position
        NodegraphAPI.SetNodePosition(new_node, pos)
        # select this node
        NodegraphAPI.SetNodeSelected(new_node, True)
    else:
        placeNode(new_node)
    return new_node
Example #5
0
def createSingleBlocker(
        root=NodegraphAPI.GetRootNode(), celExp='getParent().', topNode=True):
    #open the file contening the lua file
    #fileLua = open(__LUA_FILE_PATH,'r')
    #luaText = fileLua.read()
    # root node
    rootNode = root
    #create the groupNode
    groupNode = NodegraphAPI.CreateNode('Group', rootNode)
    groupNode.setName('Blocker1')
    name = groupNode.getName()
    #add in and out port
    groupNodeIn = groupNode.addInputPort('in')
    groupNodeOut = groupNode.addOutputPort('out')
    #add attribute to switch the display of group node to normal node
    groupNodeAttrDict = {'ns_basicDisplay': 1, 'ns_iconName': ''}
    groupNode.setAttributes(groupNodeAttrDict)
    #add the disable param
    disableParam = groupNode.getParameters().createChildNumber('disable', 0)
    newCelExp = celExp[:celExp.rfind(
        'getParent().')]  # this is a hack it work but not safe
    disableParam.setExpression(newCelExp + name + '.disable', True)
    #create user param on the groupNode if use as a single entity
    if topNode:
        paramui(groupNode, name)

    #create the opNode who create the primitive
    primitiveOpNode = NodegraphAPI.CreateNode('OpScript', parent=groupNode)
    primitiveOpNode.setName('primitiveType')
    primitiveOpNode.getParameter('applyWhere').setValue(
        'at specific location', 0)
    primitiveOpNode.getParameter('location').setExpression(
        celExp + name + '.path_Name', True)
    #create parameter
    primitiveOpNodeParam = primitiveOpNode.getParameters().createChildGroup(
        'user')
    #param for message
    primitiveOpNodeParamDisplay = primitiveOpNodeParam.createChildNumber(
        'message', 1)
    primitiveOpNodeParamDisplay.setExpression(celExp + name + '.message', True)
    #param to get the color
    primitiveOpNodeParamColor = primitiveOpNodeParam.createChildNumberArray(
        'color', 3)
    primitiveOpNodeParamColor.setExpression(celExp + name + '.color', True)
    #param to get the light
    primitiveOpNodeParamLight = primitiveOpNodeParam.createChildString(
        'light', '')
    primitiveOpNodeParamLight.setExpression(celExp + name + '.CEL', True)
    #param to get the shape
    primitiveOpNodeParamShape = primitiveOpNodeParam.createChildString(
        'shape', 'box')
    primitiveOpNodeParamShape.setExpression(celExp + name + '.blocker_Type',
                                            True)
    #this part is to use if you want the "printed script" in the lua script tab
    #filePrimitiveStart = luaText.find('--PrimitiveModule')
    #filePrimitiveEnd = luaText.find('--endPrimitiveModule')
    #primitiveOpNode.getParameter('script.lua').setValue(luaText[filePrimitiveStart:filePrimitiveEnd],0)
    #this is using a lua script as reference which mean you need to set the LUA_PATH correctly to point at the script(i.eos.environ['LUA_PATH'] = "/homes/duda/.katana/LuaScript/?.lua")
    primitiveOpNode.getParameter('script.lua').setValue(
        "local createPrimitive = require 'blocker'\ncreatePrimitive.primitive()",
        0)

    #create the transform Node
    transformNode = NodegraphAPI.CreateNode('Transform3D', parent=groupNode)
    transformNode.setName('Transform_Blocker')
    #set the path expression
    transformNode.getParameter('path').setExpression(
        celExp + name + '.path_Name', True)
    #set the interactive to Yes
    transformNode.getParameter('makeInteractive').setValue('Yes', 0)

    #create the opScriptNode for the primitive and set it's lua text to get the transform matrix
    opscriptPrimNode = NodegraphAPI.CreateNode('OpScript', parent=groupNode)
    opscriptPrimNode.setName('MatrixPrim')
    opscriptPrimNode.getParameter('CEL').setExpression(
        celExp + name + '.path_Name', True)
    #this part is to use if you want the "printed script" in the lua script tab
    #fileMatrixTextStart = luaText.find('--MatrixModule')
    #fileMatrixTextEnd = luaText.find('--endMatrixModule')
    #opscriptPrimNode.getParameter('script.lua').setValue(luaText[fileMatrixTextStart:fileMatrixTextEnd],0)
    #this is using a lua script as reference which mean you need to set the LUA_PATH correctly to point at the script(i.eos.environ['LUA_PATH'] = "/homes/duda/.katana/LuaScript/?.lua")
    opscriptPrimNode.getParameter('script.lua').setValue(
        "local createMatrix = require 'blocker'\ncreateMatrix.getMatrix()", 0)

    #create the opscript for the light
    opscriptLightNode = NodegraphAPI.CreateNode('OpScript', groupNode)
    opscriptLightNode.getParameter('CEL').setExpression(
        celExp + name + ".CEL", True)
    opscriptLightNode.setName('MatrixLight')
    opscriptLightUserParam = opscriptLightNode.getParameters(
    ).createChildGroup('user')
    opscriptLightUserParamBlocker = opscriptLightUserParam.createChildString(
        'blocker', 'blk01')
    opscriptLightUserParamBlocker.setExpression(
        celExp + name + '.blocker_Number', True)
    opscriptLightUserParamPrim = opscriptLightUserParam.createChildString(
        'primitive', '')
    opscriptLightUserParamPrim.setExpression(celExp + name + '.path_Name',
                                             True)
    listParam = ['density', 'roundness', 'width_edge', 'height_edge', 'ramp']
    for param in listParam:
        paramCreated = opscriptLightUserParam.createChildNumber(param, 0.0)
        paramCreated.setExpression(celExp + name + '.' + param, True)
    opscriptLightUserParamShape = opscriptLightUserParam.createChildString(
        'geometry_type', 'box')
    opscriptLightUserParamShape.setExpression(celExp + name + '.blocker_Type',
                                              True)
    opscriptLightUserParamAxis = opscriptLightUserParam.createChildString(
        'axis', 'x')
    opscriptLightUserParamAxis.setExpression(celExp + name + '.axis', True)
    opscriptLightUserParamFileIn = opscriptLightUserParam.createChildString(
        'fileIn', '')
    opscriptLightUserParamFileIn.setExpression(celExp + name + '.fileIn', True)
    opscriptLightUserParamUseProj = opscriptLightUserParam.createChildNumber(
        'use_projection', 0)
    opscriptLightUserParamUseProj.setExpression(
        celExp + name + '.use_projection', True)
    opscriptLightUserParamFileType = opscriptLightUserParam.createChildNumber(
        'file_type', 0)
    opscriptLightUserParamFileType.setExpression(celExp + name + '.file_type',
                                                 True)
    #noise user param
    dictParamNoise = {
        'noise_octaves': 'number',
        'noise_distortion': 'number',
        'noise_lacunarity': 'number',
        'noise_amplitude': 'number',
        'noise_scale': 'array',
        'noise_offset': 'array',
        'noise_coord_space': 'string'
    }
    for param in dictParamNoise.keys():
        paramToCreate = None
        if dictParamNoise[param] == 'number':
            paramToCreate = opscriptLightUserParam.createChildNumber(
                param, 0.0)
        elif dictParamNoise[param] == 'array':
            paramToCreate = opscriptLightUserParam.createChildNumberArray(
                param, 3)
        else:
            paramToCreate = opscriptLightUserParam.createChildString(param, '')
        paramToCreate.setExpression(celExp + name + '.noise.' + param, True)

    #this part is to use if you want the "printed script" in the lua script tab
    #fileLightStart = luaText.find('--MatrixLight')
    #fileLightEnd = luaText.find('--endMatrixLight')
    #opscriptLightNode.getParameter('script.lua').setValue(luaText[fileLightStart:fileLightEnd],0)
    #this is using a lua script as reference which mean you need to set the LUA_PATH correctly to point at the script(i.eos.environ['LUA_PATH'] = "/homes/duda/.katana/LuaScript/?.lua")
    opscriptLightNode.getParameter('script.lua').setValue(
        "local paramLight = require 'blocker'\nparamLight.applyBlockerParam()",
        0)

    #create the mergeNode
    mergeNode = NodegraphAPI.CreateNode('Merge', groupNode)
    mergeNode.setName('MergePrim')
    mergeNode.addInputPort('i0')
    mergeNode.addInputPort('i1')

    #connection
    sendGroup = groupNode.getSendPort('in')
    returnGroup = groupNode.getReturnPort('out')
    mergeNode.getInputPort('i0').connect(sendGroup)
    primitiveOpNode.getOutputPort('out').connect(
        transformNode.getInputPort('in'))
    transformNode.getOutputPort('out').connect(mergeNode.getInputPort('i1'))
    mergeNode.getOutputPort('out').connect(opscriptPrimNode.getInputPort('i0'))
    opscriptPrimNode.getOutputPort('out').connect(
        opscriptLightNode.getInputPort('i0'))
    opscriptLightNode.getOutputPort('out').connect(returnGroup)

    #placement of Nodes
    centralPos = NodegraphAPI.GetNodePosition(mergeNode)
    NodegraphAPI.SetNodePosition(primitiveOpNode,
                                 (centralPos[0] + 100, centralPos[1] + 200))
    NodegraphAPI.SetNodePosition(transformNode,
                                 (centralPos[0] + 100, centralPos[1] + 100))
    NodegraphAPI.SetNodePosition(opscriptPrimNode,
                                 (centralPos[0], centralPos[1] - 100))
    NodegraphAPI.SetNodePosition(opscriptLightNode,
                                 (centralPos[0], centralPos[1] - 200))

    #close the lua file
    #fileLua.close()

    #put the node under the mouse if single node
    if topNode:
        currentSelection = NodegraphAPI.GetAllSelectedNodes()
        for node in currentSelection:
            NodegraphAPI.SetNodeSelected(node, False)
        NodegraphAPI.SetNodeSelected(groupNode, True)
        # Get list of selected nodes
        nodeList = NodegraphAPI.GetAllSelectedNodes()
        # Find Nodegraph tab and float nodes
        nodegraphTab = UI4.App.Tabs.FindTopTab('Node Graph')
        if nodegraphTab:
            nodegraphTab.floatNodes(nodeList)

    return groupNode
def createCam(seq='s0060', camDict={}):
    # print getNewOrder(camDict)
    pos = (0, 0)
    mergeInput = 0
    maxOutTime = 0
    inputName = 'i'
    camFrame = _STARTTIME_
    # set the sart time of the project to _STARTTIME_ and end time to 500
    root = NodegraphAPI.GetRootNode()
    root.getParameter('inTime').setValue(_STARTTIME_, 0)
    root.getParameter('outTime').setValue(500, 0)

    # find the number of camera
    nbCamNode = len(camDict.keys())

    # create a group node which will contains all the camera for the sequence
    group = NodegraphAPI.CreateNode("Group", NodegraphAPI.GetRootNode())
    group.setName('PublishedCam_Group_' + seq)
    # add attribute to switch the display of group node to normal node
    groupNodeAttrDict = {'ns_basicDisplay': 1, 'ns_iconName': ''}
    group.setAttributes(groupNodeAttrDict)
    group.addOutputPort('out')
    # create parameter for the group node
    celParamOutCam = group.getParameters().createChildNumber('outputCam', 0)
    celParamOutCam.setHintString(
        "{'options__order': ['All', 'masterCam'], 'help': 'choose if all the camera of the sequences will be display in the SceneGraph or only the masterCam', 'widget': 'mapper', 'options': {'All': 0.0, 'masterCam': 1.0}}"
    )
    outTypeParam = group.getParameters().createChildNumber('outputType', 0)
    outTypeParam.setHintString(
        "{'options__order': ['stereo', 'left', 'center', 'right'], 'help': 'out cam type (i.e: stereo,Left,Center or Right)', 'widget': 'mapper', 'options': {'stereo': 0.0, 'right': 3.0, 'center': 2.0, 'left': 1.0}}"
    )
    # create the merge node which assemble al the camera
    mergeNode = NodegraphAPI.CreateNode('Merge', group)
    NodegraphAPI.SetNodeComment(
        mergeNode, "merge all the sequence cameras and the masterCam together")
    # create the switch Node
    switchNode = NodegraphAPI.CreateNode('Switch', group)
    NodegraphAPI.SetNodeComment(
        switchNode,
        "switch between all cameras to create the masterCam animation")
    switchNodeIn = switchNode.getParameter('in')

    for key in getOrder(camDict):
        # start the animation process of the switch node if we are at the startframe value
        if camFrame == _STARTTIME_:
            switchNodeIn.setAutoKey(True)
            switchNodeIn.setValueAutoKey(0, _STARTTIME_)
        # create the PublishedCamera Node
        PublishedCameraNode = NodegraphAPI.CreateNode('PublishedCamera', group)
        # set the Name of the PublishedCamera node
        PublishedCameraNode.setName('Cam_' + key)
        # set the path of the camera abc
        camFile = PublishedCameraNode.getParameter('file')
        camFile.setValue(camDict[key]['camPath'], 0)

        # set the name for the camera in the camera tree
        camName = PublishedCameraNode.getParameter('name')
        camName.setValue('/root/world/cam/Cam_' + key, 0)
        # set the position of the node
        NodegraphAPI.SetNodePosition(PublishedCameraNode, pos)
        # create a new input connection on the merge and connect the PublishedCamera node to it
        inputName = 'i' + str(mergeInput)
        mergeNode.addInputPort(inputName)
        PublishedCameraNode.getOutputPort('out').connect(
            mergeNode.getInputPort(inputName))

        # create the timeOfset node
        timeOffsetNode = NodegraphAPI.CreateNode('TimeOffset', group)
        timeOffsetNode.setName('TimeOffset_Cam' + key)
        # set value for the inputFrame parameter of the timeOffset node
        inputFrame = timeOffsetNode.getParameter('inputFrame')
        inputFrame.setExpressionFlag(False)
        inputFrame.setAutoKey(True)
        allFramesInterest = camDict[key]['frameInterest']
        # if there is multiple frameInterest loop
        for frame in allFramesInterest:
            inputFrame.setValueAutoKey(frame, camFrame)
            camFrame += 1
        inputFrame.setAutoKey(False)
        # position the timeOffset node
        NodegraphAPI.SetNodePosition(timeOffsetNode, (pos[0], pos[1] - 50))
        PublishedCameraNode.getOutputPort('out').connect(
            timeOffsetNode.getInputPort('input'))

        # create the RenameNode
        renameNode = NodegraphAPI.CreateNode('Rename', group)
        # set the name of the rename
        renameNode.setName('Rename_Cam_' + key)
        # set the rootlocation for the rename node
        renameNode.getParameter('rootLocation').setValue('/root/world/cam', 0)
        # set the pattern
        renameNode.getParameter('pattern').setValue('Cam_' + key, 0)
        # set the replace string
        renameNode.getParameter('replace').setValue('MasterCam', 0)
        # position of the rename node
        NodegraphAPI.SetNodePosition(renameNode, (pos[0], pos[1] - 100))
        # connect the publishedcam node to the rename Node
        timeOffsetNode.getOutputPort('output').connect(
            renameNode.getInputPort('in'))
        # connect the rename node to the switch node
        switchNode.addInputPort(inputName)
        renameNode.getOutputPort('out').connect(
            switchNode.getInputPort(inputName))

        # increment the input nb for the merge node
        mergeInput += 1
        # set the next key for the switch node(with inputMerge incremented) if inputMerge is less than the number of cam node
        if mergeInput < nbCamNode:
            switchNodeIn.setValueAutoKey(mergeInput, camFrame)
        else:
            switchNodeIn.setAutoKey(False)

        # increment the pos
        pos = (pos[0] + 300, pos[1])
        # find the maxOutTime
        if allFramesInterest[-1] > maxOutTime:
            maxOutTime = allFramesInterest[-1]

    # set the animation curve of the switch to be constant
    curve = switchNodeIn.getCurve()
    segments = curve.getSegments()
    for seg in segments:
        seg.setExpression('constant()')

    # position of the merge node
    mergePos = (pos[0] / 2, -300)
    NodegraphAPI.SetNodePosition(mergeNode, mergePos)

    # create the switch node to output all camera or only the master camera
    switchMasterNode = NodegraphAPI.CreateNode('Switch', group)
    switchMasterNode.setName('switchMasterNode')
    NodegraphAPI.SetNodeComment(switchMasterNode,
                                'swich to all camera or only masterCam')
    switchMasterNode.getParameter('in').setExpression('getParent().outputCam',
                                                      True)
    # connect the port
    switchMasterNode.addInputPort('i0')
    switchMasterNode.addInputPort('i1')
    mergeNode.getOutputPort('out').connect(switchMasterNode.getInputPort('i0'))
    switchNode.getOutputPort('output').connect(
        switchMasterNode.getInputPort('i1'))
    # position the switchMasterNode
    switchMasterNodePos = (mergePos[0], mergePos[1] - 50)
    NodegraphAPI.SetNodePosition(switchMasterNode, switchMasterNodePos)

    # position for the switch node
    NodegraphAPI.SetNodePosition(switchNode, (mergePos[0] + 300, -200))
    # connect the switch node to the merge node
    inputName = 'i' + str(mergeInput)
    mergeNode.addInputPort(inputName)
    switchNode.getOutputPort('output').connect(
        mergeNode.getInputPort(inputName))

    # create the opscript node to add the masterCam in the cameraList
    opscriptNode = NodegraphAPI.CreateNode('OpScript', group)
    opscriptNode.setName('addCamMasterToCamList')
    opscriptNodeParam = opscriptNode.getParameters().createChildGroup('user')
    opscriptNodeParam.createChildNumber('outCamValue', 0)
    opscriptNode.getParameter('user.outCamValue').setExpression(
        'getParent().outputCam', True)
    opscriptNodeParam.createChildNumber('outCamType', 0)
    opscriptNode.getParameter('user.outCamType').setExpression(
        'getParent().outputType', True)
    NodegraphAPI.SetNodeComment(
        opscriptNode,
        "add the masterCam center,left and right to the cameraList ")
    opscriptNode.getParameter('CEL').setValue('/root/world', 0)
    # set the script node
    # opscriptNode.getParameter('script.lua').setValue("local camVal = Interface.GetOpArg('user.outCamValue'):getValue()"
    #                                                  "\nlocal camType = Interface.GetOpArg('user.outCamType'):getValue()"
    #                                                  "\nlocal tableCamList = {}"
    #                                                  "\nif camVal == 1 then"
    #                                                  "\n\tif camType == 0 then"
    #                                                  "\n\t\ttable.insert(tableCamList,'/root/world/cam/MasterCam/stereoCamera/stereoCameraCenterCamShape')"
    #                                                  "\n\t\ttable.insert(tableCamList,'/root/world/cam/MasterCam/stereoCameraLeft/stereoCameraLeftShape')"
    #                                                  "\n\t\ttable.insert(tableCamList,'/root/world/cam/MasterCam/stereoCameraRight/stereoCameraRightShape')"
    #                                                  "\n\telseif(camType == 1) then"
    #                                                  "\n\t\ttable.insert(tableCamList,'/root/world/cam/MasterCam/stereoCameraLeft/stereoCameraLeftShape')"
    #                                                  "\n\telseif camType == 2 then"
    #                                                  "\n\t\ttable.insert(tableCamList,'/root/world/cam/MasterCam/stereoCamera/stereoCameraCenterCamShape')"
    #                                                  "\n\telse"
    #                                                  "\n\t\ttable.insert(tableCamList,'/root/world/cam/MasterCam/stereoCameraRight/stereoCameraRightShape')"
    #                                                  "\n\tend"
    #                                                  "\nelse"
    #                                                  "\n\tlocal camList = Interface.GetAttr('globals.cameraList')"
    #                                                  "\n\ttableCamList = camList:getNearestSample(0)"
    #                                                  "\n\ttable.insert(tableCamList,'/root/world/cam/MasterCam/stereoCamera/stereoCameraCenterCamShape')"
    #                                                  "\n\ttable.insert(tableCamList,'/root/world/cam/MasterCam/stereoCameraLeft/stereoCameraLeftShape')"
    #                                                  "\n\ttable.insert(tableCamList,'/root/world/cam/MasterCam/stereoCameraRight/stereoCameraRightShape')"
    #                                                  "\nend"
    #                                                  "\nInterface.SetAttr('globals.cameraList',StringAttribute(tableCamList))",0)
    opscriptNode.getParameter('script.lua').setValue(opNodeScript, 0)
    # connect the opscriptnode to the merge node
    switchMasterNode.getOutputPort('output').connect(
        opscriptNode.getInputPort('i0'))
    opscriptNodePos = (mergePos[0], mergePos[1] - 100)
    NodegraphAPI.SetNodePosition(opscriptNode, opscriptNodePos)

    # create  prunes nodes to switch off non disired cameras
    # prune for left cam
    pruneNodeLeft = NodegraphAPI.CreateNode('Prune', group)
    pruneNodeLeft.setName('leftCam_' + seq)
    # set the cel node to eliminate all camera but the left one
    pruneNodeLeft.getParameter('cel').setValue(
        "((/root/world/cam/Cam_s*/stereoCameraRight /root/world/cam/Cam_s*/stereoCamera /root/world/cam/MasterCam/stereoCameraRight /root/world/cam/MasterCam/stereoCamera))",
        0)
    # connect the merge group to the prune node
    opscriptNode.getOutputPort('out').connect(pruneNodeLeft.getInputPort('A'))
    prunePos = (mergePos[0] - 200, mergePos[1] - 200)
    NodegraphAPI.SetNodePosition(pruneNodeLeft, prunePos)
    # prune for right cam
    pruneNodeRight = NodegraphAPI.CreateNode('Prune', group)
    pruneNodeRight.setName('rightCam_' + seq)
    # set the cel node to eliminate all camera but the right ones
    pruneNodeRight.getParameter('cel').setValue(
        "((/root/world/cam/Cam_s*/stereoCameraLeft /root/world/cam/Cam_s*/stereoCamera /root/world/cam/MasterCam/stereoCameraLeft /root/world/cam/MasterCam/stereoCamera))",
        0)
    # connect the merge group to the prune node
    opscriptNode.getOutputPort('out').connect(pruneNodeRight.getInputPort('A'))
    prunePos = (mergePos[0] + 200, mergePos[1] - 200)
    NodegraphAPI.SetNodePosition(pruneNodeRight, prunePos)
    # prune for center cam
    pruneNodeCenter = NodegraphAPI.CreateNode('Prune', group)
    pruneNodeCenter.setName('centerCam_' + seq)
    # set the cel node to eliminate all camera but the center ones
    pruneNodeCenter.getParameter('cel').setValue(
        "((/root/world/cam/Cam_s*/stereoCameraRight /root/world/cam/Cam_s*/stereoCameraLeft /root/world/cam/MasterCam/stereoCameraLeft /root/world/cam/MasterCam/stereoCameraRight))",
        0)
    # connect the merge group to the prune node
    opscriptNode.getOutputPort('out').connect(
        pruneNodeCenter.getInputPort('A'))
    prunePos = (mergePos[0], mergePos[1] - 200)
    NodegraphAPI.SetNodePosition(pruneNodeCenter, prunePos)

    # create the switch node for the prune camera
    switchPrune = NodegraphAPI.CreateNode('Switch', group)
    switchPrune.setName('switchPrune')
    NodegraphAPI.SetNodeComment(switchPrune,
                                'swich to to prune the non needed camera')
    switchPrune.getParameter('in').setExpression('getParent().outputType',
                                                 True)
    # connect the port
    switchPrune.addInputPort('i0')
    switchPrune.addInputPort('i1')
    switchPrune.addInputPort('i2')
    switchPrune.addInputPort('i3')
    opscriptNode.getOutputPort('out').connect(switchPrune.getInputPort('i0'))
    pruneNodeLeft.getOutputPort('out').connect(switchPrune.getInputPort('i1'))
    pruneNodeCenter.getOutputPort('out').connect(
        switchPrune.getInputPort('i2'))
    pruneNodeRight.getOutputPort('out').connect(switchPrune.getInputPort('i3'))
    # position the switchPrune
    switchPrunePos = (mergePos[0], mergePos[1] - 300)
    NodegraphAPI.SetNodePosition(switchPrune, switchPrunePos)

    # connect the switchprune to the out port of the group
    returnGroup = group.getReturnPort('out')
    switchPrune.getOutputPort('output').connect(returnGroup)
    # set the out time of the project to maxOutTime
    root.getParameter('outTime').setValue(camFrame - 1, 0)
    print maxOutTime, camFrame

    # put the node under the mouse
    currentSelection = NodegraphAPI.GetAllSelectedNodes()
    for node in currentSelection:
        NodegraphAPI.SetNodeSelected(node, False)
    NodegraphAPI.SetNodeSelected(group, True)
    # Get list of selected nodes
    nodeList = NodegraphAPI.GetAllSelectedNodes()
    # Find Nodegraph tab and float nodes
    nodegraphTab = UI4.App.Tabs.FindTopTab('Node Graph')
    if nodegraphTab:
        nodegraphTab.floatNodes(nodeList)
Example #7
0
def selectNode(node):
    NodegraphAPI.SetNodeSelected(node, True)
Example #8
0
try:
    baseNode = NodegraphAPI.GetNode(
        NodegraphAPI.GetAllSelectedNodes()[0].getName())
except:
    sys.exit("Select a node on the nodegraph")

for i in selectedGroups:
    y = 50  #inital node position on nodegraph
    try:
        previousNode = NodegraphAPI.GetNode(
            NodegraphAPI.GetAllSelectedNodes()[0].getName())
    except IndexError:
        break
    previousNodePosition = NodegraphAPI.GetNodePosition(previousNode)
    xpos = previousNodePosition[0]
    ypos = previousNodePosition[1] - y
    t3d = NodegraphAPI.CreateNode("Transform3D", NodegraphAPI.GetRootNode())
    t3d.getParameter("path").setValue(i, 0)
    t3d.getParameter("makeInteractive").setValue("Yes", 0)
    NodegraphAPI.SetNodePosition(t3d, [xpos, ypos])
    #ports change names so trying more than one.
    try:
        previousNodePort = previousNode.getOutputPort('out')
        t3d.getInputPort('in').connect(previousNodePort)
    except:
        previousNodePort = previousNode.getOutputPort('default')
        t3d.getInputPort('in').connect(previousNodePort)
    NodegraphAPI.SetAllSelectedNodes('')
    NodegraphAPI.SetNodeSelected(t3d, True)
    y += 50  #adding space for next node in loop