Copy link to clipboard
Copied
Hi, I would need to access the ids of the graphs present in the default node library in Designer using the Python API. For example nodes such as "Cells 4" or "Switch". I can see Designer is able to extract the relevant ids from packages located into the resources/packages system folder when we right-click on a library node, we can see both the .sbs path and the graph id. For example the "auto_crop.sbs" package contains both "auto_crop_color" and "auto_crop_grayscale" graph ids. I would basically need to access this same information from the Python API, I don't think this is possible right-now.
1 Correct answer
Hello Olivier,
Unfortunately, there is indeed no way to directly the data in Designer's library database through the Python API.
To list the identifiers of graphs from Designer's default library, you may manually load its content and read it, which can be slow dependending on what you access.
Here is a sample script that does just that:
import os
from os import path
import sd
from sd.api.sdapplication import SDApplicationPath
from sd.api import SDSBSCompGraph
app = sd.getContext().getSDApp
...
Copy link to clipboard
Copied
Hello Olivier,
Unfortunately, there is indeed no way to directly the data in Designer's library database through the Python API.
To list the identifiers of graphs from Designer's default library, you may manually load its content and read it, which can be slow dependending on what you access.
Here is a sample script that does just that:
import os
from os import path
import sd
from sd.api.sdapplication import SDApplicationPath
from sd.api import SDSBSCompGraph
app = sd.getContext().getSDApplication()
pkgMgr = app.getPackageMgr()
pkgDirPath = os.path.join(app.getPath(SDApplicationPath.DefaultResourcesDir), "packages")
for pkgFilename in os.listdir(pkgDirPath):
if pkgFilename[0] == "a":
pkgPath = os.path.join(pkgDirPath, pkgFilename)
pkg = pkgMgr.loadUserPackage(pkgPath)
print(pkgFilename)
for rsc in pkg.getChildrenResources(isRecursive=True):
if isinstance(rsc, SDSBSCompGraph):
print(f" - {rsc.getIdentifier()}")
pkgMgr.unloadUserPackage(pkg)
Alternatively, you may read from the database directly in Python, without going through the API. The database uses the simple JSON format which is easy to parse. It is the resources.json file in Designer's user data:
(Windows) %LOCALAPPDATA%/Adobe/Adobe Substance 3D Designer/databases/resources.json
(macOS) ~/Library/Application Support/Adobe/Adobe Substance 3D Designer/databases/resources.json
The graph identifiers are stored in the "basename" key.
I hope this is helpful!
Copy link to clipboard
Copied
Thank you Luca! This looks great, I will try this and let you know.
Copy link to clipboard
Copied
This is working great @Luca Giarrizzo ! I am using resources.json as it contains info about which graphs are in the library and visible. If possible it would be nice to have an API function to retrieve the path and filename of this resource.json file.

