View Full Version : How to run a script everytime when the file is saved ?
09-18-2010, 11:27 AM
Hi everybody, I wrote a script for creating thumbnail for the active file and I want to run the script every time when a file is saved which will also update thumbnail, :hmm: but i'm stuck at running it everytime after file save happens, can anybody help me for the same, thankx in advance.
09-18-2010, 02:35 PM
Maybe you could try to copy the maya scripts which are relevant to the operation "save"(eg. Maya2011\scripts\startup\FileMenu.mel) to your user profile scripts directory and insert your call routines into those copied scripts. There is more information in "Modify a Maya start-up script" (http://mayastation.typepad.com/maya-station/2009/04/modify-a-maya-startup-script.html) from Maya station.
Hope this will help. :)
09-18-2010, 06:47 PM
Are you using python or MEL?
If you are using Python, you can just register a callback with the API:
import maya.OpenMaya as api
saveCallback = api.MSceneMessage.addCallback(
print 'About to save!'
and you can remove it like this:
If you are using MEL, you may be able to do it with a scriptJob, if you look through the list of events. Someone with more MEL experience might be able to offer some other ideas though..
09-22-2010, 08:03 AM
Hello friends, thanx a lot for your replies, it worked for me, i'm using mel i never used python but willing to try and switch to it for building plugins, well thanks again :)
09-23-2010, 12:04 PM
whoar cool! That callback-adding sheds quite some more light on python :D very nice!
In Mel just wanted to suggest to override the FileMenu_SaveItem proc. Easy as that. Just lookup whats inside there and write your own proc.
But this would not catch if you'd save the file via "Save As...". But that would also be changable.
You could also hook into the Hotkeys like Ctrl+S.
For scriptJob: There is no fileSaved-scriptJob.
10-01-2010, 11:17 AM
thats a nice feature and Ive added that as a check when saving a file, but
Im having a problem ..
when user has modified the scene and wants to open another one and maya asks if he/she
wants to save the changes to the current one and that save goes past all
kBeforeSave and kBeforeSaveCheck.. arghhh
10-01-2010, 11:23 AM
hmm.. it seems to that kBeforeSaveCheck can prevent the saving in that situation BUT
it prevents also from opening a second file..
10-01-2010, 11:23 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.