Skip to main content
Participant
June 23, 2023
Answered

Which nodes can be created through the Scripting API?

  • June 23, 2023
  • 1 reply
  • 375 views

Hi,

For example :

graph.newNode("sbs::compositing::uniform")
Creates a new uniform node in my Substance Designer graph, great.
 
Besides uniform, which other ones can be created this way?
 
I've been trying to find a function that returns the complete list of nodes. The closest one so far seems to be :
node.getDefinition().getLabel())
This returns Uniform Color
 
And 2nd question, is it possible to spawn a graph from a sbrar imported resource?
Thanks!
This topic has been closed for replies.
Correct answer Cyril Dellenbach

Hello @Bjorn_AltaVR,

 

Thanks for the question.

 

All the Atomic Nodes can be created from the way you mentionned upthere. You'll find the entire list under 
Help > Scripting Documentation > Modules definition > sbs::compositing

 

For instance nodes, this will require to locate and open the package file, find the desired graph, create a node and close the package:

import sd
# from sd.api import sdproperty
app = sd.getContext().getSDApplication()
# Get managers
ui_mgr = app.getQtForPythonUIMgr()
pkg_mgr = app.getPackageMgr()
# Get current graph
graph = ui_mgr.getCurrentGraph()
# Load target package
my_package = pkg_mgr.loadUserPackage("D:/OneDrive - Adobe/test_files/sbsar/test/tst-islands.sbsar")
print(my_package.getFilePath())
# Find target graph resource in target package
for item in my_package.getChildrenResources(isRecursive=True😞
	if item.getIdentifier() == "test_islands":
	 tgt_resource = item
# Create nodes
my_levels_node = graph.newNode("sbs::compositing::levels")
my_instance_node = graph.newInstanceNode(tgt_resource)
# Close target package
pkg_mgr.unloadUserPackage(my_package)

 

Same thing goes for .SBSAR

 

Best regards,

 

1 reply

Cyril Dellenbach
Community Manager
Cyril DellenbachCommunity ManagerCorrect answer
Community Manager
June 30, 2023

Hello @Bjorn_AltaVR,

 

Thanks for the question.

 

All the Atomic Nodes can be created from the way you mentionned upthere. You'll find the entire list under 
Help > Scripting Documentation > Modules definition > sbs::compositing

 

For instance nodes, this will require to locate and open the package file, find the desired graph, create a node and close the package:

import sd
# from sd.api import sdproperty
app = sd.getContext().getSDApplication()
# Get managers
ui_mgr = app.getQtForPythonUIMgr()
pkg_mgr = app.getPackageMgr()
# Get current graph
graph = ui_mgr.getCurrentGraph()
# Load target package
my_package = pkg_mgr.loadUserPackage("D:/OneDrive - Adobe/test_files/sbsar/test/tst-islands.sbsar")
print(my_package.getFilePath())
# Find target graph resource in target package
for item in my_package.getChildrenResources(isRecursive=True😞
	if item.getIdentifier() == "test_islands":
	 tgt_resource = item
# Create nodes
my_levels_node = graph.newNode("sbs::compositing::levels")
my_instance_node = graph.newInstanceNode(tgt_resource)
# Close target package
pkg_mgr.unloadUserPackage(my_package)

 

Same thing goes for .SBSAR

 

Best regards,

 

Cyril Dellenbach (Micro) | QA Support Artist | Adobe
Participant
July 10, 2023

Perfect, thank you very much.

One more question, do you know how to expose parameters like this through Python ? Thank you