View Full Version : file command - open in new instance of maya

01 January 2013, 05:43 PM
Is that even possible in MEL / python?

I'd like to open a file in a new instance of maya with a "file -open" command.
If that's not possible in mel/python, is there another way?


01 January 2013, 12:56 AM
Cant be done with the file command. You can do it with the system command using Mel. The code below outta do it. Just replace the $file with the file you wish to open.

string $file = "C:/test/";
string $maya = `getenv maya_location`+"/bin/maya.exe";
system ("start "+ $maya + " " + $file);

I forgot about the python code. It's not as friendly as the Mel, i'm sure people will comment on a cleaner way to do it.

import maya.cmds as cmds
import maya.mel as mel
import os

mayaDir = mel.eval('getenv maya_location')
maya = str(mayaDir+'/bin/maya.exe')
mayaDirShortName = maya.replace("Program Files", "Progra~1")

mayaFile = "C:/test/"
os.system("start "+ mayaDirShortName + " " + mayaFile)

01 January 2013, 11:34 AM

Works like a charm! :)

CGTalk Moderation
01 January 2013, 11:34 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.