Sunday, September 29, 2013

Save and Reload Selection [Maya Python]

This is a Python script for Maya that can save your selection and reload it at a later point in your session.
 ## --------------------------------------------------------------------  
 """   
 Title: AC_RememberSelection.py  
 Author: Andrew Kin Fun Chan  
 Email: AndrewChan1985@gmail.com  
 Date: Sept 2013  
 Version: 1.0  
 Compatibility: Maya 2011+ (It will probably work in older versions as well. Contact me if you have issues.)  
 Function:        Commands:  
 Load Selection:     reloadSel = AC_RememberSelection(1)  
 Reload Selection:    AC_RememberSelection(0)  
 """  
 ## --------------------------------------------------------------------  
 import maya.cmds as mc  
 def AC_RememberSelection(x):  
   if x == 1:  
     print 'Storing Selection'  
     loadSel = mc.ls(sl=True)  
   else:  
     print 'Reloading Selection.'  
     mc.select (reloadSel)  
   return (loadSel)  

No comments: