Best way to get notified when Maya scene is saved, or undo is called?

1,101 views
Skip to first unread message

Michael Boon

unread,
Feb 5, 2014, 10:40:54 PM2/5/14
to python_in...@googlegroups.com
I'm making a Qt GUI, and I need to update it when certain things in the Maya scene change.

What's the best way to get a callback, Qt signal or some other notification when
- the Maya file is saved under a new name
- a new Maya scene is opened
- undo or redo are executed
?

I'm not very experienced with Maya programming. I've heard of ScriptJobs but haven't looked into them. Is that where I should be looking?

Thanks,

Boon

Donal McMullan

unread,
Feb 5, 2014, 10:57:07 PM2/5/14
to python_in...@googlegroups.com
Hey Michael -

You may want to capture some of the events detailed on this page:
http://download.autodesk.com/us/maya/2011help/API/class_m_scene_message.html

Using OpenMaya.MSceneMessage.addCallback

Cheers

D
> --
> You received this message because you are subscribed to the Google
> Groups "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to python_inside_m...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/d6ee0082-8dd7-404a-9df2-4cf6538eb37e%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.


--

Donal McMullan
Production Engineer
Desk: x6411
Direct: +64 4909 6651
Mobile: +64 2166 1254

Mark Jackson

unread,
Feb 6, 2014, 4:08:36 AM2/6/14
to python_inside_maya
Yeah we do exactly this to intercept the file open and fire some health checks after the scene has loaded:

import maya.OpenMaya as api
api.MSceneMessage.addCallback(api.MSceneMessage.kAfterOpen, funct_to_call)



On 6 February 2014 03:57, Donal McMullan <dmcm...@wetafx.co.nz> wrote:
Hey Michael -

You may want to capture some of the events detailed on this page:
http://download.autodesk.com/us/maya/2011help/API/class_m_scene_message.html

Using OpenMaya.MSceneMessage.addCallback

Cheers

D



On 06/02/14 16:40, Michael Boon wrote:
I'm making a Qt GUI, and I need to update it when certain things in the Maya scene change.

What's the best way to get a callback, Qt signal or some other notification when
- the Maya file is saved under a new name
- a new Maya scene is opened
- undo or redo are executed
?

I'm not very experienced with Maya programming. I've heard of ScriptJobs but haven't looked into them. Is that where I should be looking?

Thanks,

Boon
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
--

Donal McMullan
Production Engineer
 Desk: x6411
 Direct: +64 4909 6651
 Mobile: +64 2166 1254
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/52F30813.7050005%40wetafx.co.nz.

For more options, visit https://groups.google.com/groups/opt_out.



--
-------------------------------------
Mark Jackson
Technical Animation Director
http://markj3d.blogspot.com/

Marcus Ottosson

unread,
Feb 6, 2014, 4:30:37 PM2/6/14
to python_in...@googlegroups.com
How about making your own save, load, undo/redo methods, add your own callbacks and such and finally replace those normally found in menus or via hotkeys.

A disadvantage may be that your tool would only work in an environment that allows for this. But if you are, the advantages lies in the separation of your pipeline and the inner workings of Maya, which may come in use when tools misbehave or when an increased control over when and where signals fire is required.


To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAGQH2FFnKLCS_nu3w8eoGWAJo73KBj3UNEp4TS7drfYedEY6-A%40mail.gmail.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Marcus Ottosson
konstr...@gmail.com

Marcus Ottosson

unread,
Feb 6, 2014, 4:34:32 PM2/6/14
to python_in...@googlegroups.com
Also, an alternative to the solution posted above is the "script" node, that can be set to execute a snippet of Python/MEL code on a few scene events and also persists across scenes.

--
Marcus Ottosson
konstr...@gmail.com

Michael Boon

unread,
Feb 6, 2014, 6:08:58 PM2/6/14
to python_in...@googlegroups.com
Thanks all.

I did as Cuchullain and Mark suggested and that works well. I had no idea that these API M....Message() functions even existed.

aevar.gu...@gmail.com

unread,
Feb 7, 2014, 2:38:19 AM2/7/14
to python_in...@googlegroups.com
  Keep in mind, as Marcus suggested, keeping a separation between your saves and your tools means if anything goes wrong, at all, your users won’t be left without a saved file.  Idiot proofing your code is not about you not having confidence in your tool, there are some geniuses out there who really don’t consider anything beyond their own desk when it comes to deployment. 

  For example, something as seemingly simple as adding a print statement into that call-back without explicitly stating the pipe buffer you want to print to (print >> sys.stderr,’oops’)  can come back and bite your tool very hard when the IT heads decide once day to alter the pipes so their shell navigation tools work better.

  Hard to fathom but I’ve literally seen a UNIX setup that’s capable of breaking the direction of the pipe buffer causing massive errors on prints in Maya (that’s why and when I had to learn the >> method of printing so people could save their files during the week that was fixed)

To be failsafe and relatively idiot-guarded:
  -First do a local save with nothing other than Maya’s internal workings.
  -Then do whatever metadata manipulation, notifications or logging you need to do.
  -Then distribute your files.
  -Give a second notification to a support personnel if the distribution didn’t deliver.

  It is more steps, but if what you are building then becomes the next super-tool in the world of saving/loading and general scene access you’ll be thankful to not have to account for why dozens of artists on a deadline are not able to deliver their work.

  Hope this helps
Reply all
Reply to author
Forward
0 new messages