I'm trying to create a plugin for Painter that will simplify some of the things my team and I have to do manually. One of those things is to toggle elements in the Display Settings, like the ToneMapper Function. Looking at the Python API documentation, it should be possible by checking the current state with and if and then setting the tone mapper to the other function.
Here's my approach so far:
def toggleToneMap():
toneMapper = substance_painter.display.get_tone_mapping()
new_tone_mapping = substance_painter.display.ToneMappingFunction.ACES
if toneMapper == "ToneMappingFunction.ACES":
new_tone_mapping = substance_painter.display.ToneMappingFunction.Linear
print(new_tone_mapping)
else:
new_tone_mapping = substance_painter.display.ToneMappingFunction.ACES
substance_painter.display.set_tone_mapping(new_tone_mapping)
substance_painter.display.get_tone_mapping returns ' [Python] ToneMappingFunction.Linear ' in the log. So unless I'm missing something, my approach should work. But alas, it goes straight to the else and doesn't seem to produce the nice toggle that need.
I tried replacing the "ToneMappingFunction.ACES" by ' [Python] ToneMappingFunction.Linear ', didn't help.
Also tried with just the value, like "ACES", didn't work either.
Even tried " if "ACES" in toneMapper: " as a method and I'm getting a Type error in the log
[Python] if "ACES" in toneMapper:
[Python] TypeError
[Python] :
[Python] argument of type '_substance_painter.display.ToneMappingFunction' is not iterable
Can anyone tell me what I'm doing wrong or point me in a direction where I should be looking?