Python "it" Scripting
|
Introduction
Menu items can be added to the Commands menu of the 'it' window relatively easily.
Pixar's document,
To function as a menu item the Thumbnail.py script must, import it, os from it.It3Command import It3Command class Thumbnail(It3Command): def __init__(self): self.m_menuPath = 'Commands/Save Thumbnail' def Invoke(self): self.save_thumbnail() def save_thumbnail(self, gamma=1.0,quality=100): element = it.GetCurrentElement() image_name = element.GetLabel() + '.jpg' cwdpath = os.getcwd() path = os.path.join(cwdpath, image_name) self.saveImage(element, path, 2.2, 100) it.app.Info('The thumbnail has been saved as "%s"' % os.path.abspath(path)) it.app.RaiseLogWindow() def saveImage(self, element,path,gamma,quality): image = element.GetImage() image = image.Gamma(gamma); # dimensions, True preserve aspect ratio, True crop to preserve aspect ratio image = image.Reformat([0,150,0,150], True, True) image.SetMetaDataItem('JPEG_QUALITY', quality) image.Save(path, ice.constants.FMT_JPEG) it.commands.append(Thumbnail) |
Installing & Loading the Script
Save the python script in your custom "it" scripts
directory. For example, the "RfM: Customizing"
tutorial recommends using this directory,
|
LoadExtension python "C:/Users/YOUR_NAME/Documents/maya/rfm_scripts/image_tool//Thumbnail.py" |
If the user has set an environment variable called |
LoadExtension python "[GetEnv MAYA_USER_DIR]/rfm_scripts/image_tool/Thumbnail.py" |
© 2002- Malcolm Kesson. All rights reserved.