Author Topic: Substance Designer API graph inputs  (Read 1408 times)

Hi everyone! I'm a newbie at substance designer scripting, and the lack of examples drives me crazy :(
For example, I have a graph which converts resources from PBR to our custom Blinn Phong (convert multiple inputs to one diffuse), and I want to run this graph on hundreds of resources. I've created some script that will collect all the data, substitute it, and save results in corresponding folders, but I have a huge problem figuring out how to substitute the graph's values. I tried setting values inside my graph (by setting values of SDProperties from SDPropertyCategory.Output of each Input) (InsideToPhong.png/py). I tried setting values outside of my graph (by setting values of SDProperties from SDPropertyCategory.Input of ToPhong node) (OutsideOfToPhong.png/py), but I always get the same error:
Code: [Select]
[ERR][3]Traceback (most recent call last):
[ERR][4]  File "D:/SubstanceScripts/", line 106, in <module>
[ERR][7]  File "D:/SubstanceScripts/", line 92, in run
[ERR][9]computeToPbr(decalpathes[0], sbsCompGraph)
[ERR][10]  File "D:/SubstanceScripts/", line 46, in computeToPbr
[ERR][12]setTextureById(sbsCompGraph, 'BaseColor', baseColorTex)
[ERR][13]  File "D:/SubstanceScripts/", line 32, in setTextureById
[ERR][15]tex.setPropertyValue(prop, sdvaluetexture)
[ERR][16]  File "C:/Program Files/Allegorithmic/Substance Designer/resources/python\sd\api\", line 157, in setPropertyValue
[ERR][18]raise APIException(SDApiError(_res))

How to achieve the desired behavior? I do believe that there also has to be a much more elegant way of handling this. Any help would be appreciated!


Textures cannot be set for node properties. They are always computed from the graph and read only.
You could create a resource for each input that you need, create a new node and connect it and then compute the graph,
but there is a better way to do what you are trying to do.

Use input nodes in your graph for inputs. Export an sbsar for your graph and then you can use sbsrender to inject the bitmaps into the inputs and render the outputs of your graph.

You can make a script that calls sbsrender using Python's subprocess module and automate the process for many inputs.

Also there is another problem in your script. SD API is in general not thread safe. You cannot use it from threads.

Last Edit: November 12, 2020, 12:01:56 pm