def _maintained_selection_decorator(func):
"""Function decorator to maintain the selection once called
Example:
>>> @_maintained_selection
... def my_function():
... # Modify selection
... cmds.select(clear=True)
...
>>> # Selection restored
"""
def wrapper(*args, **kwargs):
previous_selection = cmds.ls(selection=True)
try:
return func(*args, **kwargs)
finally:
if previous_selection:
cmds.select(previous_selection,
replace=True,
noExpand=True)
else:
cmds.select(deselect=True,
noExpand=True)
return wrapper
评论列表
文章目录