SubstancePainterのメッシュをReload
from PySide2 import QtWidgets
import substance_painter.project as sp_prj
import substance_painter.ui as sp_ui
import substance_painter.logging as sp_log
plugin_widgets = []
def on_mesh_reload(status: sp_prj.ReloadMeshStatus):
path = sp_prj.last_imported_mesh_path()
if status == sp_prj.ReloadMeshStatus.SUCCESS:
sp_log.info("The mesh was reloaded successfully.\n Import mesh : {}".format(path))
else:
sp_log.info("The mesh couldn't be reloaded.")
def excute_ReloadMesh():
#プロジェクトが開いてない時
if not sp_prj.is_open():
sp_log.warning("A project is not opened.")
return
#最後に更新したメッシュパスを取得
get_last_imported_mesh_path = sp_prj.last_imported_mesh_path()
#インポート設定
mesh_reloading_settings = sp_prj.MeshReloadingSettings(import_cameras=False, preserve_strokes=True)
# Reload the current mesh:
sp_prj.reload_mesh(get_last_imported_mesh_path, mesh_reloading_settings, on_mesh_reload)
def start_plugin():
sp_log.info("Loaded Plugin : reload_mesh")
# UIアクション設定
reload_mesh = QtWidgets.QAction("Reload Mesh")
reload_mesh.triggered.connect(excute_ReloadMesh)
sp_ui.add_action(sp_ui.ApplicationMenu.Edit, reload_mesh)
plugin_widgets.append(reload_mesh)
def close_plugin():
sp_log.info("Unloaded Plugin : reload_mesh")
"""This method is called when the plugin is stopped."""
plugin_widgets.clear()
if __name__ == "__main__":
start_plugin()
編集タブにReloadMeshの項目が追加されるのでクリックすると更新されます