1

I want to know filename what will be opened before opening.

Maya have the callback: kBeforeOpen

But when i try to read file name in callback function - i receive a name of current file but not file that will be opened.

def before(*args, **kwargs):
    print('scene_name', cmds.file(q=True, sn=True))

om.MSceneMessage.addCallback(om.MSceneMessage.kBeforeOpen, before)

in empty scene i trying to open file: "C:/tmp/pen_01.mb".

log told me that command file -o "C:/tmp/pen_01.mb" is started and then started callback

>>> file -options "v=0;" -typ "mayaBinary" -o "C:/tmp/pen_01.mb";
>>> ('scene_name', u'')

As you can see, function reads current file name (empty).

How in callback function read information about what exactly will be opened?

Massimo
  • 836
  • 3
  • 17
  • 38

1 Answers1

2

In OpenMaya you can do:

OpenMaya.MFileIO.beforeOpenFilename()
haggi krey
  • 1,885
  • 1
  • 7
  • 9
  • This is strange that I can't find such class or function in Maya Python API 2.0 (maya.api.OpenMaya). But using Python API 1.0 it works fine. Thank you. – ababak Mar 01 '21 at 09:14