substance_painter_plugins模組
此模組允許管理 Substance 3D Painter 插件:列出現有插件、載入或卸載特定插件等。
Substance 3D Painter 外掛是一個標準的 Python 模組,放置在新增 substance_painter_plugins.path於 的路徑中,可使用 Substance 3D Painter Python API 來執行特定任務。
範例
import importlib
import substance_painter_plugins
# Get the list of available Plugin names:
all_plugins_names = substance_painter_plugins.plugin_module_names()
for name in all_plugins_names:
print(name)
# Load the "hello world" Plugin:
plugin = importlib.import_module("hello_plugin")
# Start the Plugin if it wasn't already:
if not substance_painter_plugins.is_plugin_started(plugin):
substance_painter_plugins.start_plugin(plugin)
substance_painter_plugins.path = [] substance_painter_plugins.path
一串字串,用來指定外掛搜尋路徑。 初始化自 SUBSTANCE_PAINTER_PLUGINS_PATH 環境變數、Substance 3D Painter 安裝目錄及 Substance 3D Painter 使用者資源目錄。
更新這個變數後,你需要明確呼叫 substance_painter_plugins.update_sys_path 。
一個插件目錄預期包含三個子目錄,這些子目錄會自動加入:sys.path
- 插件 :作為可選元件載入的模組。
- 啟動 模組:應用程式啟動時總是載入的模組。
- 模組 :工具模組,跨插件共享。
模組與plugins/startup/目錄中預期會有 a start_plugin() 和 a close_plugin() 方法,分別在載入模組後和卸載前呼叫。新增 plugins/ 於目錄中的模組優先於新增 startup/ 於目錄中的模組。
類型: 列表
substance_painter_plugins.plugins substance_painter_plugins.plugins
目前已啟動的插件回傳。
類型: dict
substance_painter_plugins.start_plugin(module) substance_painter_plugins.start_plugin
啟動給出的 Substance 3D Painter 外掛。
參數:模組 – 一個預期包含start_plugin方法的 Python 模組。
substance_painter_plugins.close_plugin(module, gc_collect=True) substance_painter_plugins.close_plugin
關閉給定的 Substance 3D Painter 插件。
參數:
- 模組 – 一個預期包含
close_plugin方法的 Python 模組。 - gc_collect – 如果設定為 True,請執行完整的垃圾回收。
substance_painter_plugins.is_plugin_started(module) substance_painter_plugins.is_plugin_started
檢查該插件是否已啟動。
參數:模組 – Python 模組。
回報:True如果該模組目前已開始False,否則。
substance_painter_plugins.reload_plugin(module) substance_painter_plugins.reload_plugin
重新載入一個插件並啟動它。
請閱讀 importlib.reload(module) 文件 以了解可能的注意事項。 請參閱 start_plugin() 及 close_plugin() 關於啟動與關閉插件的詳細資訊。 如果外掛有 reload_plugin 方法,該方法會在關閉且重新啟動外掛前執行。 此 reload_plugin 方法的目的是手動重新載入該外掛所依賴的所有子模組(例如外掛是 Python 套件)。
參數:模組 – Python 模組。
回歸: 重新載入的插件模組。
substance_painter_plugins.startup_module_names() substance_painter_plugins.startup_module_names
列出可用的 啟動 模組名稱。
退回: 所有可用 啟動 模組的名稱。
回傳類型: 列表[str]
substance_painter_plugins.plugin_module_names() substance_painter_plugins.plugin_module_names
列出可用的 插件名稱、 模組名稱。
回傳: 所有可用 插件 模組的名稱。
回傳類型: 列表[str]
substance_painter_plugins.load_startup_modules() substance_painter_plugins.load_startup_modules
載入所有啟動模組。
substance_painter_plugins.close_all_plugins() substance_painter_plugins.close_all_plugins
關閉所有已啟動的插件。
substance_painter_plugins.update_sys_path() substance_painter_plugins.update_sys_path
根據substance_painter_plugins.path環境SUBSTANCE_PAINTER_PLUGINS_PATH變數進行更新sys.path。