Create Uniform Color with preset value through python
Hello Can anyone give me an example like create a uniform color node in current graph and set the output size to 8x8? I want to study python in SD and need some example to move on
Thanks
Hello Can anyone give me an example like create a uniform color node in current graph and set the output size to 8x8? I want to study python in SD and need some example to move on
Thanks
Hello @Max_Steven,
This should do the trick:
import sd
from sd.api import *
app = sd.getContext().getSDApplication()
ui_mgr = app.getUIMgr()
# Get the graph currently in the currently active Graph view
graph = ui_mgr.getCurrentGraph()
# Create a new Uniform Color node
my_node = graph.newNode("sbs::compositing::uniform")
# Set the inheritance method of the node's Output Size property to Absolute
my_node.setInputPropertyInheritanceMethodFromId(
"$outputsize",
sdproperty.SDPropertyInheritanceMethod(2)
)
# Set the node's Output Size property value to (4, 4)
my_node.setInputPropertyValueFromId(
"$outputsize",
sdvalueint2.SDValueInt2.sNew(sdbasetypes.int2(4, 4))
)
# Set the node's Output Color property value to (1, 1, 0, 1)
my_node.setInputPropertyValueFromId(
"outputcolor",
sdvaluefloat4.SDValueFloat4.sNew(sdbasetypes.float4(1, 1, 0, 1))
)
In the Help menu of Substance 3D Designer, you can find the Scripting documentation option which will open the Python API Reference in your web browser. I strongly recommend keeping this resource handy while scripting.
The Scripting section of Designer's documentation will also help get you started.
I hope this is helpful!
Best regards.
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.