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

[Python Scripting] Writing Project Metadata when saving the project

New Here ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

Hello there!

I am currently experiencing some trouble while developing a python plugin for the newest Substance Painter version (8.1.2).

Lets say I want to save some string data from my plugin to the project file, when the project file is saved.

My current approach is to write that into the projects metadata, when the project is about to be saved, using the substance_painter.project and substance_painter.events module.

Consider the following pseudocode:

 

import substance_painter.events
import susbtance_painter.project

class PseudoClass:
    def __init__(self):
    ...
    self.event_dispatcher = substance_painter.events.DISPATCHER
    self.event_dispatcher.connect(substance_painter.events.ProjectAboutToSave, self.save_settings)
    ...

    def save_settings(self, event):
        metadata = substance_painter.project.Metadata("PluginSaveData")
        metadata.set("plugin_save_data", "testsavedata")

 

This should work in theory, but sadly raises the following Error instead:

[Python] File "C:\Program Files/Adobe/Adobe Substance 3D Painter/resources/python/modules\substance_painter\project.py", line 794, in set
_substance_painter.project.set_metadata(self._context + "/" + key, value)

[Python] _substance_painter.exception.ProjectError: The project is locked.

As far as my understanding goes that Error is raised before and after saving, so i could not attach it to any of the save events. (Trying to write metadata works neither in the "ProjectAboutToSave" nor using the "ProjectSaved" event

A workaround i tried is to attach the saving process to the "BusyStatusChanged" Event instead, but appereantly Painter doesn't count as "busy" when saving a file.
Using substance_painter.project.execute_when_not_busy() also doesnt work.

And with no more events left at my disposal, I came here to ask if anyone possibly has a solution.


Thanks a lot already for any replies!

TOPICS
Scripting

Views

108

Likes

Translate

Translate

Report

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
Adobe Employee ,
Aug 30, 2022 Aug 30, 2022

Copy link to clipboard

Copied

LATEST

Hello,

 

Sorry for the late reply.

I have discussed a bit with the team about your request and use-case, and unfortunately right now we don't have a way to do what you want. I have logged that request and we are going to look into it.

Likes

Translate

Translate

Report

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
Resources