Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Access library node ids using the Python API

Contributor ,
Feb 28, 2025 Feb 28, 2025

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.

TOPICS
Scripting , Substance Graph
253
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Employee , Mar 05, 2025 Mar 05, 2025

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
...
Translate
Adobe Employee ,
Mar 05, 2025 Mar 05, 2025

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!

Luca Giarrizzo | Quality Engineer, 3D & Immersive | Adobe
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 05, 2025 Mar 05, 2025

Thank you Luca! This looks great, I will try this and let you know.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Mar 09, 2025 Mar 09, 2025
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines