Notifications
Clear all

[Closed] Scripted modifier on delete

I have a scripted mod that assigns new material to object in attachedToNode event.
How do I revert to original material when removing modifier from stack?
Neither ‘on delete do’ nor ‘on detachedFromNode’ events seem to fire on removing.

3 Replies

‘on delete do’ and ‘on detachedFromNode’ won’t fire up right away after you delete the modifier so you could store the original material in a #material parameter and use a #preModifierDeleted or #postModifierDeleted callback to restore the material. You can register the callback in the ‘on attachedToNode’ event and make it persistent so it is saved with your scene.

Thanks. That’s what I actually do right now.
One question remains, what’s the best way of handling modifier enable/disable state?

when parameters $.modifiers[ modName ] changed ...

Should I apply these When costructs to all my custom modifiers on scene load or maybe there’s a better way of making it persistent?

you can setup preModifierDeleted callback only once, for all your modifier instances at the same time.
in the body of your plugin.