def test_motion(self):
        '''Change the PxrUsdIn's file and verify the dumped result.'''

        # test.motion.usda is a UsdGeomPointInstancer with positions,
        # orientations, scales, velocities, and angular velocities
        NodegraphAPI.GetNode('PxrUsdIn').getParameter('fileName').setValue(
            'test.motion.usda', 0)
        CacheManager.flush()

        testfile = 'test.motion.xml'
        AttrDump.AttrDump(testfile)
        self.assertTrue(os.path.exists(testfile))

        self.cleanUpTestFile(testfile)
        self.assertTrue(self.compareAgainstBaseline(testfile))
def createMtoAArnoldShadingNodes():
    def getAllMtoAArnoldShadingTypes():
        import RenderingAPI
        result = []
        # Obtain a list of names of available shaders from the renderer info plug-in
        renderer = RenderingAPI.RenderPlugins.GetDefaultRendererPluginName()
        rendererInfoPlugin = RenderingAPI.RenderPlugins.GetInfoPlugin(renderer)
        shaderType = RenderingAPI.RendererInfo.kRendererObjectTypeShader
        nodeTypes = rendererInfoPlugin.getRendererObjectNames(shaderType)

        for node_type in nodeTypes:
            if node_type.startswith("Maya") or node_type.startswith("Mtoa"):
                result.append(node_type)
        return result

    from Katana import NodegraphAPI
    shader_type_list = getAllMtoAArnoldShadingTypes()
    result = []
    i = 0
    for shader_type in shader_type_list:
        as_node = NodegraphAPI.GetNode(shader_type)

        if not as_node:
            as_node = NodegraphAPI.CreateNode('ArnoldShadingNode',
                                              NodegraphAPI.GetRootNode())
            width = 5
            NodegraphAPI.SetNodePosition(
                as_node, (150 * math.floor(i / width), -50 * (i % width)))
            i += 1

        as_node.getParameter('nodeType').setValue(shader_type, 0)
        as_node.checkDynamicParameters()
        as_node.getParameter('name').setValue(shader_type, 0)

        result.append(as_node)
    return result
Exemplo n.º 3
0
def create_puppet_group(knode, contents, position, ing):
    '''
    :description create asset groups and its dependency nodes 
    :param knode <NodegraphAPI node object>
    :param contents <dict>
    :param position <list>
    :param ing <int>
    '''
    puppet_group = NodegraphAPI.CreateNode('Group', parent=knode)
    puppet_group.setName('%s_group' % contents['name'])
    NodegraphAPI.SetNodePosition(puppet_group, position)
    puppet_group.addOutputPort('out')
    merge_node = create_merge_node([0, 0], puppet_group, contents['name'])
    input_port = merge_node.addInputPort('input')
    look_resolve, look_assign = None, None
    if contents['category'] != 'camera':
        look_resolve = NodegraphAPI.CreateNode('LookFileResolve',
                                               parent=puppet_group)
        look_resolve.setName('%s_resolve' % contents['name'])
        look_resolve.getOutputPort('out').connect(input_port)
        look_assign = NodegraphAPI.CreateNode('LookFileAssign',
                                              parent=puppet_group)
        look_assign.setName('%s_klf' % contents['name'])
        look_assign.getOutputPort('out').connect(
            look_resolve.getInputPort('A'))
        input_port = look_assign.getInputPort('input')
        klf_parameter = look_assign.getParameter('args.lookfile.asset')
        expression = get_expression('lookdev', contents['category'],
                                    contents['name'], 'i3')
        klf_parameter.getChild('value').setExpression(expression)
        klf_parameter.getChild('enable').setValue(True, 1.0)
        cel_parameter = look_assign.getParameter('CEL')
        puppet_location = os.path.join(studio_nodes.SCENE_GRAPH_LOCATION,
                                       contents['category'], contents['name'])
        cel_parameter.setValue(puppet_location.encode(), 1.0)
    alembic_node = NodegraphAPI.CreateNode('Alembic_In', parent=puppet_group)
    alembic_node.setName('%s_alembic' % contents['name'])
    alembic_node.getOutputPort('out').connect(input_port)
    scenegraph_location = os.path.join(studio_nodes.SCENE_GRAPH_LOCATION,
                                       contents['category'])
    name_parameter = alembic_node.getParameter('name')
    name_parameter.setValue(scenegraph_location.encode(), 1.0)
    name_parameter.setUseNodeDefault(False)
    abc_parameter = alembic_node.getParameter('abcAsset')
    expression = get_expression('animation', contents['category'],
                                contents['name'], 'i5')
    abc_parameter.setExpression(expression)
    abc_parameter.setUseNodeDefault(False)
    # set the position
    x, y = [0, 100]
    for each in [look_resolve, look_assign, alembic_node]:
        if not each:
            continue
        NodegraphAPI.SetNodePosition(each, [x, y])
        y += ing
    return puppet_group
def ActionCallback(value):
    """
    Callback for the layered menu, which creates a PrmanShadingNode node and
    sets its B{nodeType} parameter to the given C{value}, which is the name of
    a PRMan shader as set for the menu entry in L{PopulateCallback()}.

    @type value: C{str}
    @rtype: C{object}
    @param value: An arbitrary object that the menu entry that was chosen
        represents. In our case here, this is the name of a PRMan shader as
        passed to the L{LayeredMenuAPI.LayeredMenu.addEntry()} function in
        L{PopulateCallback()}.
    @return: An arbitrary object. In our case here, we return the created
        PrmanShadingNode node, which is then placed in the B{Node Graph} tab
        because it is a L{NodegraphAPI.Node} instance.
    """
    # Create the node, set its shader, and set the name with the shader name
    node = NodegraphAPI.CreateNode('ArnoldShadingNode')

    node.getParameter('nodeType').setValue(value, 0)
    node.setName(value)
    node.getParameter('name').setValue(node.getName(), 0)
    NodegraphAPI.SetNodeEdited(node, True, True)
    return node
Exemplo n.º 5
0
        def __go(self, checked=False):
            node = NodegraphAPI.GetNode(self.__assetName)

            from Katana import UI4
            attributeFile = UI4.Util.AssetId.BrowseForAsset(
                '', 'Select file', False, {
                    'fileTypes': 'xml',
                    'context': AssetAPI.kAssetContextAttributeFile
                })

            if not attributeFile:
                return

            self.__itemClass.appendAttributeFile(attributeFile,
                                                 self.__assetName)
Exemplo n.º 6
0
 def set_parent(self):
     selected_nodes = NodegraphAPI.GetAllSelectedNodes()
     if not selected_nodes:
         return
     output_ports = selected_nodes[-1].getOutputPorts()
     outport = None
     inputport = None
     for output_port in output_ports:
         connected_port = output_port.getConnectedPorts()
         outport = output_port
         if not connected_port:
             continue
         inputport = connected_port[-1]
         break
     if outport:
         outport.connect(self.getInputPort('input'))
     dx, dy = 0, 0
     if inputport:
         self.getOutputPort('output').connect(inputport)
         dx, dy = NodegraphAPI.GetNodePosition(inputport.getNode())
     ux, uy = NodegraphAPI.GetNodePosition(selected_nodes[-1])
     mx = (ux + dx) / 2
     my = (uy + dy) / 2
     NodegraphAPI.SetNodePosition(self, [mx, my])
Exemplo n.º 7
0
        def __go(self, checked=False):
            node = NodegraphAPI.GetNode(self.__assetName)

            from Katana import UI4
            lookFile = UI4.Util.AssetId.BrowseForAsset(
                '', 'Select file', False, {
                    'fileTypes': 'klf',
                    'acceptDir': True,
                    'context': AssetAPI.kAssetContextLookFile
                })

            if not lookFile:
                return

            self.__itemClass.appendLookFile(lookFile, self.__assetName)
Exemplo n.º 8
0
def normal_render(render_node, render_mode, frame_ranges):
    if isinstance(render_node, str) or isinstance(render_node, unicode):
        render_node = NodegraphAPI.GetNode(render_node)
    if not render_node:
        print '#warnings: not a valid render node'
        return
    for index in range(frame_ranges[0], frame_ranges[1]):
        # RenderManager.RenderModes.DISK_RENDER
        settings = RenderManager.RenderingSettings()
        settings.frame = index
        settings.mode = render_mode
        settings.asynchRenderMessageCB = messageHandler
        settings.asynch = False
        RenderManager.StartRender(render_mode,
                                  node=render_node,
                                  settings=settings)
Exemplo n.º 9
0
def get_studio_nodes(key, value=None):
    # group_nodes = NodegraphAPI.GetAllNodesByType('Group', includeDeleted=False)
    k_nodes = NodegraphAPI.GetAllNodes(includeDeleted=False)
    studio_nodes = {}
    for k_node in k_nodes:
        parameter = k_node.getParameter(key)
        if not parameter:
            continue
        node_value = parameter.getValue(1.0)
        if value:
            if parameter.getValue(1.0) != value:
                continue
            studio_nodes.setdefault(k_node, node_value)
        else:
            studio_nodes.setdefault(k_node, node_value)
    return studio_nodes
Exemplo n.º 10
0
def WireInlineNodes(enclosingGroup, nodeList, x=0, y=0):
    # Position all nodes in the nodeList and connect them to each other
    for i in xrange(0, len(nodeList)):
        NodegraphAPI.SetNodePosition(nodeList[i], (x, i * -50 + y))
        if i == 0:
            continue
        nodeList[i].getInputPortByIndex(0).connect(
            nodeList[i - 1].getOutputPortByIndex(0))

    # Connect enclosing group, if one is specified
    if enclosingGroup:
        nodeList[0].getInputPortByIndex(0).connect(
            enclosingGroup.getSendPort(
                enclosingGroup.getInputPortByIndex(0).getName()))
        nodeList[-1].getOutputPortByIndex(0).connect(
            enclosingGroup.getReturnPort(
                enclosingGroup.getOutputPortByIndex(0).getName()))
Exemplo n.º 11
0
def getAll():
    node = NodegraphAPI.GetViewNode()
    runtime = FnGeolib.GetRegisteredRuntimeInstance()
    txn = runtime.createTransaction()
    client = txn.createClient()
    op = Nodes3DAPI.GetOp(txn, node)
    txn.setClientOp(client, op)
    runtime.commit(txn)

    locationPathsAndData = []
    traversal = FnGeolib.Util.Traversal(client, "/root")
    while traversal.valid():
        locationPathsAndData.append(
            (traversal.getLocationPath(), traversal.getLocationData()))
        traversal.next()
    for i in locationPathsAndData:
        print i
Exemplo n.º 12
0
def connectAndPlaceNodes(groupNode):
    noNodes = groupNode.getNumChildren()
    stepSize = -80

    counter = 0
    lastNode = groupNode.getChildByIndex(0)
    for n in groupNode.getChildren():
        if n.getType() == "Alembic_In":
            pass
        else:
            counter = counter + 1
            NodegraphAPI.SetNodePosition(n, (0, stepSize * counter))
            lastNode.getOutputPortByIndex(0).connect(n.getInputPortByIndex(0))
            lastNode = n

    # Connect last node to return port
    lastNode.getOutputPortByIndex(0).connect(groupNode.getReturnPort('out'))
Exemplo n.º 13
0
def get_katana_nodes(nodes):
    '''
    :description find the node in the scene with given name
    :param nodes <list>
    :example
        from core import nodegraph
        nodes = ['katana_camera', 'PrimitiveCreate', 'camera_abc', 'test_node']
        nodegraph.get_katana_nodes(nodes)    
    '''
    knodes = []
    for node in nodes:
        if isinstance(node, str) or isinstance(node, unicode):
            knode = NodegraphAPI.GetNode(node)
        else:
            knode = node
        if knode:
            knodes.append(knode)
    return knodes
Exemplo n.º 14
0
def getParameters(parameter_name='',
                  node=[],
                  param_type='any',
                  matchMode='tail'):
    '''
    set the given parameter and value on the selected(or given) node
    input parameter name should be a list or string
    the returned type is a dict if given the parameter_name: 
        {parameter_name:[parameter_object, ...]}
    or a list if the parameter_name is invalid, in this case, we simply list all parameters:
        [parameter_name, ...]
    '''
    if not node:
        sel = NodegraphAPI.GetAllSelectedNodes()
    else:
        sel = node
        if not isinstance(sel, list):
            sel = [sel]
    if not isinstance(parameter_name, list):
        parameter_name = [parameter_name]
    if parameter_name and parameter_name[0]:
        collections = {}
    else:
        collections = []

    for s in sel:
        #get the parameters
        params = traverseParameterGroup(s.getParameters())
        for p in params:
            if param_type != 'any' and p.getType() != param_type:
                continue
            if parameter_name and parameter_name[0]:
                for n in parameter_name:
                    if ( matchMode=='tail' and p.getFullName().lower().endswith(n.lower()) ) or \
                        ( matchMode=='include' and n.lower() in p.getFullName().lower() ):
                        if collections.has_key(n):
                            collections[n].append(p)
                        else:
                            collections.update({n: [p]})
                        print p.getFullName()
            else:
                collections.append(p)
                print p.getFullName()
    return collections
Exemplo n.º 15
0
    def _get_all_render_node_paths(self):
        """
        Get all the paths and their enabled state from all the render nodes.

        :rtype: `dict`
        """
        if not hasattr(self, "__render_paths"):
            def false_factory():
                return False
            render_paths = defaultdict(false_factory)
            render_nodes = NodegraphAPI.GetAllNodesByType("Render")
            for node in render_nodes:
                outputs = node.getParameter("outputs")
                locations = [x.getValue(0) for x in outputs.getChild("locations").getChildren()]
                enabled_flags = [x.getValue(0) for x in outputs.getChild("enabledFlags").getChildren()]
                for path, enabled in zip(locations, enabled_flags):
                    render_paths[path] |= bool(enabled)  # At least one enabled to make it enabled
            self.__render_paths = dict(render_paths)
        return self.__render_paths
def PopulateCallback(layeredMenu):
    """
    The populate call back is given to the layeredMenu as an argument.  This
    function will determine what options are displayed to the user when the user
    displays the layered menu.
    """
    display_flag = getGSVDisplayFlag()
    gsv_parm = NodegraphAPI.GetNode('rootNode').getParameter('variables')
    if display_flag is False:
        gsv_name = getGSV()
        gsv_entry = gsv_parm.getChild('%s.options' % gsv_name)
        for child in gsv_entry.getChildren():
            layeredMenu.addEntry(str(child.getValue(0)),
                                 text=str(child.getValue(0)),
                                 color=(128, 0, 128))
    else:
        for child in gsv_parm.getChildren():
            layeredMenu.addEntry(str(child.getName()),
                                 text=str(child.getName()),
                                 color=(0, 128, 128))
Exemplo n.º 17
0
def get_selected_nodes(single=False):
    """
    Get selected nodes from the node graph, if single is given will
    check if a single node is selected.

    Kwargs:
        single (bool): single node selection
    
    Returns:
        list. Selected nodes.
    
    #FIXME (eze) this should return arrays, even is single is on
    """
    nodes = NodegraphAPI.GetAllSelectedNodes()
    if single:
        if len(nodes) != 1:
            raise RuntimeError("Please select 1 node.")
        return nodes[0]
    else:
        return nodes
Exemplo n.º 18
0
    def __updateCB(self, args):
        if self.__updateTreeOnIdle:
            return

        for arg in args:
            if arg[0] in ('port_connect', 'port_disconnect'):
                for nodeNameKey in 'nodeNameA', 'nodeNameB':
                    nodeName = arg[2][nodeNameKey]
                    node = NodegraphAPI.GetNode(nodeName)
                    if node is not None and node.getParent() == self.__node:
                        self.__updateTreeOnIdle = True
                        return

            if arg[0] in ('parameter_finalizeValue'):
                node = arg[2].get('node')
                param = arg[2].get('param')
                if node.getParent(
                ) == self.__node and param == node.getParameter('name'):
                    self.__updateTreeOnIdle = True
                    return
Exemplo n.º 19
0
    def __buildNodeChildren(self, nodeItem, selectedItems):
        node = NodegraphAPI.GetNode(nodeItem.getItemData()['name'])

        for param in node.getParameter('parameters').getChildren():
            name = param.getName()
            if name == '__unused':
                continue

            if param.getType() != 'group':
                continue

            item = QT4Widgets.SortableTreeWidgetItem(nodeItem, name)

            key = hash(param)
            item.setItemData({'name': param.getName(), 'key': key})

            if key in selectedItems:
                item.setSelected(True)

            self.__updateParamItem(item, param)
Exemplo n.º 20
0
def get_asset_input_data(knode):
    asset_data = {}
    pipe_parameter = knode.getParameter('studio_pipe')
    asset_node = pipe_parameter.getChild('asset_node').getValue(1.0)
    kasset_node = NodegraphAPI.GetNode(asset_node)
    if not kasset_node:
        return asset_data
    parameters = kasset_node.getParameters()
    for category in parameters.getChildren():
        if category.getName() not in studio_nodes.CATEGORIES:
            continue
        for asset in category.getChildren():
            if asset.getType() != 'stringArray':
                continue
            model = asset.getChild('i1').getValue(1.0)
            lookdev = asset.getChild('i3').getValue(1.0)
            animation = asset.getChild('i5').getValue(1.0)
            data = {'model': model, 'lookdev': lookdev, 'animation': animation}
            asset_data.setdefault(asset.getName(), data)
    return asset_data
Exemplo n.º 21
0
def InitializeNode(smNode):
    smNode.hideNodegraphGroupControls()
    smNode.addInputPort('inputScene')
    smNode.addInputPort('sharedDeps')
    smNode.addOutputPort('originalScene')

    # Merge node exists so that we have a valid scene even with
    # nothing plugged in
    mergeNode = NodegraphAPI.CreateNode('Merge', smNode)
    mergeNode.addInputPort('i0').connect(
            smNode.getSendPort('inputScene'))


    mergeDot = NodegraphAPI.CreateNode('Dot', smNode)
    mergeDot.getInputPortByIndex(0).connect(mergeNode.getOutputPortByIndex(0))
    attr = mergeDot.getAttributes()
    attr['ns_basicDisplay'] = True
    mergeDot.setAttributes(attr)

    sceneDot1 = NodegraphAPI.CreateNode('Dot', smNode)
    sceneDot1.getInputPortByIndex(0).connect(mergeDot.getOutputPortByIndex(0))
    sceneDot1.getOutputPortByIndex(0).connect(
            smNode.getReturnPort('originalScene'))


    sharedDepDotNode = NodegraphAPI.CreateNode('Dot', smNode)
    sharedDepDotNode.getInputPortByIndex(0).connect(
            smNode.getSendPort('sharedDeps'))

    NodegraphAPI.SetNodePosition(mergeNode, (-200, 100))
    NodegraphAPI.SetNodePosition(mergeDot, (-200, 0))
    NodegraphAPI.SetNodePosition(sharedDepDotNode, (100, 100))

    NodegraphAPI.SetNodePosition(sceneDot1, (-350, RENDER_NODE_POSITION))

    AddNodeReferenceParam(smNode, 'mergeNode', mergeNode)
    AddNodeReferenceParam(smNode, 'mergeDot', mergeDot)
    AddNodeReferenceParam(smNode, 'sharedDepDotNode', sharedDepDotNode)
Exemplo n.º 22
0
def get_re_texture_nodes():
    """ Get all Redshift TextureSampler Nodes

    Returns:
        dict: Dictionnary of KatanaNode:[file_path value, file_path_parameter]

    """

    texture_sampler_dict = {}  # init the dict

    all_node_list = NodegraphAPI.GetAllNodesByType('RedshiftShadingNode',
                                                   includeDeleted=False,
                                                   sortByName=True)
    for ktnnode in all_node_list:
        # check if you can get the type of the node
        try:
            node_type_value = ktnnode.getParameter("nodeType").getValue(0)
        except:
            continue

        if node_type_value == "TextureSampler":
            # try to get the file_path in the TextureSampler
            ts_path_param = ktnnode.getParameter('parameters.tex0.value')
            try:
                file_path = str(ts_path_param.getValue(0))
            except Exception as excp:
                logger.warning(
                    "Cannot get the filepath for node {}: {}".format(
                        ktnnode, excp))
                continue  # skip to the next item

            if file_path:
                texture_sampler_dict[ktnnode] = [
                    os.path.normpath(file_path), ts_path_param
                ]

    if texture_sampler_dict:
        return texture_sampler_dict
    else:
        raise ValueError("No textures find in scene")
Exemplo n.º 23
0
def get_re_texture_nodes():
    """ Get all Render Engine Katana Texture/File nodes

    Returns:
        dict: Dictionnary of {KatanaNode:[file_path value, file_path_parameter]}
    Raises:
        ValueError
    """
    retex_node_dict = {}

    all_node_list = NodegraphAPI.GetAllNodesByType('________TO CHANGE______',
                                                   includeDeleted=False,
                                                   sortByName=True)
    for ktnnode in all_node_list:
        # check if you can get the type of the node
        try:
            node_type_value = ktnnode.getParameter("nodeType").getValue(0)
        except:
            continue

        if node_type_value == "________TO CHANGE______":
            # try to get the file_path in the TextureSampler
            ts_path_param = ktnnode.getParameter('________TO CHANGE______')
            try:
                file_path = str(ts_path_param.getValue(0))
            except Exception as excp:
                logger.warning(
                    "Cannot get the filepath for node {}: {}".format(
                        ktnnode, excp))
                continue  # skip to the next item

            if file_path:
                retex_node_dict[ktnnode] = [
                    os.path.normpath(file_path), ts_path_param
                ]

    if retex_node_dict:
        return retex_node_dict
    else:
        raise ValueError("No textures find in scene")
Exemplo n.º 24
0
def addLookFileNodes(groupNode, lookRef, lookCel, ignore='False'):
    # -- node graph --
    noAssigns = 0
    
    assignNodes = []
    for childNode in groupNode.getChildren():
        if childNode.getType() == "LookFileAssign":
            assignNodes.append(childNode)
        
    # - LookFileAssign -
    nodeKstdAssign = NodegraphAPI.CreateNode('LookFileAssign')
    nodeKstdAssign.setParent( groupNode )
    nodeKstdAssign.getParameter( 'CEL' ).setExpressionFlag( True )
    nodeKstdAssign.getParameter( 'CEL' ).setExpression( lookCel )
    nodeKstdAssign.getParameter( 'args.lookfile.asset.enable' ).setValue( 1, 0 )
    nodeKstdAssign.getParameter( 'args.lookfile.asset.value' ).setValue( lookRef, 0 )
    assignNodes.append(nodeKstdAssign)

    if ignore == 'True':
        nodeKstdAssign.setBypassed(True)
        
    return nodeKstdAssign
Exemplo n.º 25
0
def RenameRenderPass(renderPass, newName):
    now = NodegraphAPI.GetCurrentTime()
    smNode = renderPass.getParent()
    oldName = renderPass.getName()

    # Return early if the name was not changed
    if oldName == newName:
        return oldName

    # Make sure new name is unique
    newName = GetUniquePassName(smNode, newName)

    # Update parameter
    renderPass.getGroupNode().setName(newName)

    # Update group name
    renderPass.getGroupNode().getParameter('passName').setValue(newName, now)

    # Rebuild outputs of Shadow Manager node
    BuildOutputs(smNode)

    return newName
Exemplo n.º 26
0
    def __createOpScriptNode(cls, parentNode, nodeName, opScript):
        """
        Creates and returns an OpScript node with the given name, under the
        given parent node, and sets the text of the OpScript to the given Lua
        code. The OpScript node will be set to run at the location of this
        package.

        @type parentNode: C{NodegraphAPI.Node}
        @type nodeName: C{str}
        @type opScript: C{str}
        @rtype: C{NodegraphAPI.Node}
        @param parentNode: The enclosing Group node under which to create the
            new OpScript node.
        @param nodeName: The name to give the new OpScript node.
        @param opScript: The text of the Lua code for the OpScript node.
        @return: The newly created OpScript node.
        """
        opScriptNode = NodegraphAPI.CreateNode('OpScript', parentNode)
        opScriptNode.setName(nodeName)
        opScriptNode.getParameter('CEL').setExpression("=^/__gaffer.location")
        opScriptNode.getParameter('script.lua').setValue(opScript, 0)
        return opScriptNode
def ActionCallback(value):
    """
    The ActionCallback is given to the LayeredMenu as an argument.  This function
    will determine what should happen when the user selects an option in the
    LayeredMenu.
    """
    # flip display flag
    display_flag = getGSVDisplayFlag()
    if display_flag is True:
        # set flags to allow recursion through menus
        setGSV(value)
        setGSVDisplayFlag(not display_flag)
        """
        hacky force update on the nodegraph tabs layer stack

        This is going to log an error, as we're manually removing the layer from the GL
        layer stack, and Katana will do this again during cleanup.
        """
        node_graph = UI4.App.Tabs.FindTopTab('Node Graph').getNodeGraphWidget()
        layer_stack = node_graph._NodegraphWidget__nodeGraphViewInteractionLayer.layerStack(
        )
        last_layer = layer_stack.getLayers()[-1]
        node_graph._NodegraphWidget__nodeGraphViewInteractionLayer.layerStack(
        ).removeLayer(last_layer)
        # layer_stack.setGraphInteraction(True)

        global gsvMenu
        node_graph.showLayeredMenu(gsvMenu)
        return
    else:
        setGSVDisplayFlag(not display_flag)
        gsv_parm = NodegraphAPI.GetNode('rootNode').getParameter('variables')
        if display_flag is False:
            gsv_name = getGSV()
            gsv_parm = gsv_parm.getChild('%s.value' % gsv_name)
            gsv_parm.setValue(value, 0)

    return value
Exemplo n.º 28
0
def addAttributeFileNodes(groupNode,
                          attrRef,
                          attrCel,
                          attrCustomBrowser='',
                          groupName='attributeFile',
                          ignore='False',
                          createNode='True'):
    if createNode == 'True':
        # - AttributeFile_In -
        attrFileIn = NodegraphAPI.CreateNode('AttributeFile_In')
        attrFileIn.setParent(groupNode)
        attrFileIn.getParameter('CEL').setExpressionFlag(True)
        attrFileIn.getParameter('CEL').setExpression(attrCel)
        attrFileIn.getParameter('filepath').setValue(attrRef, 0)
        attrFileIn.getParameter('sofilepath').setValue(attrCustomBrowser, 0)
        if groupName is not None and groupName != '':
            attrFileIn.getParameter('groupAttr').setValue(groupName, 0)

        if ignore == 'True':
            attrFileIn.setBypassed(True)

        return attrFileIn
    return None
Exemplo n.º 29
0
def ActionCallback(value):
    """
    Callback for the layered menu, which creates a PrimitiveCreate node and
    sets its B{type} parameter to the given C{value}, which is the name of
    a primitive as set for the menu entry in L{PopulateCallback()}.

    @type value: C{str}
    @rtype: C{object}
    @param value: An arbitrary object that the menu entry that was chosen
        represents. In our case here, this is the name of a primitive as
        passed to the L{LayeredMenuAPI.LayeredMenu.addEntry()} function in
        L{PopulateCallback()}.
    @return: An arbitrary object. In our case here, we return the created
        PrimitiveCreate node, which is then placed in the B{Node Graph} tab
        because it is a L{NodegraphAPI.Node} instance.
    """
    # Create the node, set its function, and set the name with the function name
    # In this case it makes the type of primitive you asked for and makes sure it has a unique name.
    node = NodegraphAPI.CreateNode('PrimitiveCreate')
    node.getParameter('type').setValue(value, 0)
    node.setName(value)
    node.getParameter('name').setValue('/root/world/geo/' + node.getName(), 0)
    return node
Exemplo n.º 30
0
def xml_element_to_katana_scene(katana_scene, xml_element, force=False):
    '''
    :description to create katana scene from xml element,
        force true is to overwrite the scene, if scene exists
    :param katana_scene <str>
    :param xml_element <PyXmlIO.Element>    
    :param force <bool>
    :example
        from core import scene
        katana_scene = '/venture/shows/katana_tutorials/tmp/export_03.katana'
        scene.xml_element_to_katana_scene(katana_scene, xml_element)      
    '''
    if os.path.isfile(katana_scene) and not force:
        print '#warnings: already found katana scene'
        return
    if not os.path.isdir(os.path.dirname(katana_scene)):
        os.makedirs(os.path.dirname(katana_scene))
    NodegraphAPI.WriteKatanaFile(katana_scene,
                                 xml_element,
                                 compress=True,
                                 archive=True,
                                 opaqueParams=None)
    return True