Skip to content

Instantly share code, notes, and snippets.

@EricTRocks
Created June 14, 2017 17:13
Show Gist options
  • Save EricTRocks/7f7f4eb3995f636dd0a10cc67a376557 to your computer and use it in GitHub Desktop.
Save EricTRocks/7f7f4eb3995f636dd0a10cc67a376557 to your computer and use it in GitHub Desktop.
How to set metadata on Canvas nodes through Python
import FabricEngine.Core
import pymel.core as pm
from maya import cmds
# Create Maya Canvas Node and preset instance
nodeName = cmds.createNode('canvasNode', name='myGraph')
dummyVec3NodeName = cmds.FabricCanvasInstPreset(
mayaNode=nodeName,
execPath="",
presetPath="Fabric.Exts.Math.Constants.Vec3")
# Get the client, host, and graph binding
contextID = pm.FabricCanvasGetContextID()
options = {
'contextID': contextID,
'guarded': True
}
client = FabricEngine.Core.createClient(options)
dfgHost = client.getDFGHost()
opBindingID = cmds.FabricCanvasGetBindingID(node=nodeName) # Change node to the name of an existing canvasNode
opBinding = dfgHost.getBindingForID(opBindingID)
graphExec = opBinding.getExec()
# Get the Node
vec3NodeName = graphExec.getNodeName(0)
nodeType = graphExec.getNodeType(0)
nodeExec = graphExec.getSubExec(vec3NodeName)
# Set the Meta data
graphExec.setNodeMetadata(nodeExec.getExecPath(), 'curveIdx', 'blah', False, False)
print graphExec.getNodeMetadata(nodeExec.getExecPath(), 'curveIdx')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment