User Guide Cancel

Accessing graphs and selections | Substance 3D Designer

Accessing graphs and selections

The SDApplication class contains some helpful methods that let you access the currently active graph, and the current selection within it.

import sd
# Get the application and UI manager object.
ctx = sd.getContext()
app = ctx.getSDApplication()
uiMgr = app.getQtForPythonUIMgr()
# Get the current graph.
g = uiMgr.getCurrentGraph()
print("The current graph is %s" % g)
# Get the currently selected nodes.
selection = uiMgr.getCurrentGraphSelectedNodes()
for node in selection:
print("Node %s" % node)
import sd # Get the application and UI manager object. ctx = sd.getContext() app = ctx.getSDApplication() uiMgr = app.getQtForPythonUIMgr() # Get the current graph. g = uiMgr.getCurrentGraph() print("The current graph is %s" % g) # Get the currently selected nodes. selection = uiMgr.getCurrentGraphSelectedNodes() for node in selection: print("Node %s" % node)
import sd 
 
# Get the application and UI manager object. 
ctx = sd.getContext() 
app = ctx.getSDApplication() 
uiMgr = app.getQtForPythonUIMgr() 
 
# Get the current graph. 
g = uiMgr.getCurrentGraph() 
print("The current graph is %s" % g) 
 
# Get the currently selected nodes. 
selection = uiMgr.getCurrentGraphSelectedNodes() 
for node in selection: 
 print("Node %s" % node)

A graph displayed in a specific Graph view can be accessed using a graphViewID.

This method is useful when creating custom graph view toolbars. The Creating toolbars in Graph views sample in the Creating user interface elements chapter provides further details.

Get help faster and easier

New user?