1
Substance Designer - Scripting - Substance Designer API graph inputs
on: November 10, 2020, 03:55:33 pm
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:
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!

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]
[MSG][2]SDApiError.DataIsReadOnly
[ERR][3]Traceback (most recent call last):
[ERR][4] File "D:/SubstanceScripts/CreateMiscMaps.py", line 106, in <module>
[ERR][5]
[ERR][6]run()
[ERR][7] File "D:/SubstanceScripts/CreateMiscMaps.py", line 92, in run
[ERR][8]
[ERR][9]computeToPbr(decalpathes[0], sbsCompGraph)
[ERR][10] File "D:/SubstanceScripts/CreateMiscMaps.py", line 46, in computeToPbr
[ERR][11]
[ERR][12]setTextureById(sbsCompGraph, 'BaseColor', baseColorTex)
[ERR][13] File "D:/SubstanceScripts/CreateMiscMaps.py", line 32, in setTextureById
[ERR][14]
[ERR][15]tex.setPropertyValue(prop, sdvaluetexture)
[ERR][16] File "C:/Program Files/Allegorithmic/Substance Designer/resources/python\sd\api\sdnode.py", line 157, in setPropertyValue
[ERR][17]
[ERR][18]raise APIException(SDApiError(_res))
[ERR][19]sd.api.apiexception
[ERR][20].
[ERR][21]APIException
[ERR][22]:
[ERR][23]SDApiError.DataIsReadOnly
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!