I'm posting another entry from my old blog, this time it's a decorator for Softimage that help us to wrap all the calls inside a function in an unique undo.
The decorator itself should look something like this...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import wraps | |
def OneUndo(function): | |
@wraps(function) | |
def _decorated(*args, **kwargs): | |
try: | |
Application.BeginUndo() | |
f = function(*args, **kwargs) | |
finally: | |
Application.EndUndo() | |
return f | |
return _decorated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@OneUndo | |
def CreateNulls(size=100): | |
return [Application.ActiveSceneRoot.AddNull() | |
for i in range(size)] | |
CreateNulls() |
Have Fun!
0 comentarios:
Post a Comment