What scene was just imported?

48 views
Skip to first unread message

Mark Dietel

unread,
Aug 9, 2016, 5:57:16 PM8/9/16
to Python Programming for Autodesk Maya
Hey guys,

I'm trying to catch some data about scenes that are imported.

Something like:


def import_callback():
   
print "SOMETHING WAS IMPORTED. I WISH I KNEW WHAT IT WAS"
   
cmds
.scriptJob( event=("SceneImported", import_callback) )



 It feels like a scriptJob callback is the way to go but I don't think it can capture the name/path of the file being imported.  Anyone have any insight or an alternate approach to calling some python on every import (and getting the name/path of the file imported)?

Thanks in advance. 

Justin Israel

unread,
Aug 9, 2016, 6:23:21 PM8/9/16
to Python Programming for Autodesk Maya
Hey Mark! Happy early birthday...

Maybe you could hook into the "before import check"?

import maya.OpenMaya as om

def catchFileImport(ret, fileObj, *args):
    print "Importing:", fileObj.resolvedFullName()
    om.MScriptUtil.setBool(ret, True)

mid = om.MSceneMessage.addCheckFileCallback(om.MSceneMessage.kBeforeImportCheck, catchFileImport)

Justin


--
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/47ea9d82-c3f0-4352-add2-3f34c2b534d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark Dietel

unread,
Aug 9, 2016, 6:30:56 PM8/9/16
to Python Programming for Autodesk Maya
Oh, man.  This looks like exactly what I want.  

.....and thanks for the BDay wishes. ;)


On Tuesday, August 9, 2016 at 3:23:21 PM UTC-7, Justin Israel wrote:
Hey Mark! Happy early birthday...

Maybe you could hook into the "before import check"?

import maya.OpenMaya as om

def catchFileImport(ret, fileObj, *args):
    print "Importing:", fileObj.resolvedFullName()
    om.MScriptUtil.setBool(ret, True)

mid = om.MSceneMessage.addCheckFileCallback(om.MSceneMessage.kBeforeImportCheck, catchFileImport)

Justin


On Wed, Aug 10, 2016 at 9:57 AM Mark Dietel <mdi...@gmail.com> wrote:
Hey guys,

I'm trying to catch some data about scenes that are imported.

Something like:


def import_callback():
   
print "SOMETHING WAS IMPORTED. I WISH I KNEW WHAT IT WAS"
   
cmds
.scriptJob( event=("SceneImported", import_callback) )



 It feels like a scriptJob callback is the way to go but I don't think it can capture the name/path of the file being imported.  Anyone have any insight or an alternate approach to calling some python on every import (and getting the name/path of the file imported)?

Thanks in advance. 

--
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.
Reply all
Reply to author
Forward
0 new messages