PDA

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


jocorok
01-18-2013, 05:43 PM
Hey.
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?

THX

Mondo
01-23-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/test.ma";
string $maya = `getenv maya_location`+"/bin/maya.exe";
system ("start "+ $maya + " " + $file);


Edit:
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/test.ma"
os.system("start "+ mayaDirShortName + " " + mayaFile)

jocorok
01-23-2013, 11:34 AM
Excelent!

Works like a charm! :)

CGTalk Moderation
01-23-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.