1xinghuan / usdNodeGraph

A Node Graph editor for USD.
125 stars 14 forks source link

UsdNodeGraph

screenshot01

You can use the node view to preview the usd file and simply edit the usd file, such as overriding prim, switching variants, adding references or payloads, and modifying attributes.

See USD Workflow

Current Support

NodeGraph:

Node:

See more in Supports

Dependence

Plugins

usdview:

screenshot01

export PYTHONPATH=$USD_NODEGRAPH_ROOT/lib/python:$PYTHONPATH
export PYTHONPATH=$USD_NODEGRAPH_ROOT/plugin:$PYTHONPATH
export PXR_PLUGINPATH_NAME=$USD_NODEGRAPH_ROOT/plugin:$PXR_PLUGINPATH_NAME

maya:

maya01

export PYTHONPATH=$USD_NODEGRAPH_ROOT/lib/python:$PYTHONPATH

import mayaUsd.ufe
from maya import cmds

def whenParameterChanged(**kwargs):
    # proxy shape not update when stage changed, so use refresh() to force updating the view
    if kwargs.get('node').Class() in ['AttributeSet', 'Transform']:
        cmds.refresh()

def whenChangesApplied(**kwargs):
    cmds.refresh()

def whenStateFrameChanged(**kwargs):
    cmds.currentTime(kwargs.get('time'))

proxyShape = '|world|s00|s00Shape'
stage = mayaUsd.ufe.getStage(proxyShape)

import usdNodeGraph.api as usdNodeGraphApi

usdNodeGraphApi.UsdNodeGraph.registerActionShortCut('open_file', None)
usdNodeGraphApi.UsdNodeGraph.registerActionShortCut('save_layer', None)
usdNodeGraphApi.GraphState.addCallback('layerChangesApplied', whenChangesApplied)
usdNodeGraphApi.GraphState.addCallback('parameterValueChanged', whenParameterChanged)
usdNodeGraphApi.GraphState.addCallback('stageTimeChanged', whenStateFrameChanged)

nodeGraph = usdNodeGraphApi.UsdNodeGraph()

nodeGraph.show()
nodeGraph.setStage(stage)

Api

import usdNodeGraph.api as usdNodeGraphApi

usdNodeGraphApi.Node.setParamDefault('PrimDefine', 'label', '/[value primName]')
usdNodeGraphApi.Node.registerActions([])  # see plugin/usdViewNodeGraph.py example
usdNodeGraphApi.Parameter.getParameterTypes()  # support parameter types
usdNodeGraphApi.GraphState.setCurrentTime(time, stage)
usdNodeGraphApi.GraphState.addCallback(callbackType, func)

TODO

Known Issues