
codeheadwords.com
codeheadwordsPython Contexts in Maya. May 13, 2015. July 29, 2016. Python’s contexts are a powerful feature and if you’re writing any kind of pipeline or animation tools, you should know about them. From contextlib import contextmanager import maya.OpenMaya as om @contextmanager def keepSelection(): # setup sel = om.MSelectionList() om.MGlobal.getActiveSelectionList(sel) yield #cleanup om.MGlobal.setActiveSelectionList(sel). The context is ready to maintain Maya’s selection when running any code in the block. The key...
http://www.codeheadwords.com/