Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

MEL command to open current scene without saving

Anonymous

MEL command to open current scene without saving

Anonymous
Not applicable

Is there a MEL command to open my current Maya scene again without saving? I'm using Maya 2016, and I'm fairly new at scripting in general.

 

Before exporting an animation for my game engine, I need to delete the namespace of my referenced character. However, I can't save the animation scene without the namespaces, otherwise the animation will be lost forever (but the namespace will be back). It means that each time I want to export, I need to:


1. Save my scene;
2. Delete namespaces (merge with root);

3. Select my meshes and bones;
4. Export my selection;
5. Close my scene without saving;
6. Open same scene again.

 

For now, I found a way to do step 2-4:

 

namespace -mergeNamespaceWithRoot -removeNamespace "model";
SelectAllPolygonGeometry;
select -add Root ;
ExportSelection

 

I don't know why, but if I add "SaveScene" at the beginning, it will disregard the Namespace and ExportSelection commands. Also, I didn't find any MEL command that would "open scene", choose the current one automatically, then choose "Don't Save".

 

If possible, I'd like to create a button to do all of these steps in one click. The most important thing to me is to find a way to execute step 5 and 6.


Thank you!

0 Likes
Reply
Accepted solutions (1)
1,934 Views
4 Replies
Replies (4)

tkaap2
Autodesk
Autodesk

In case this is helpful, I have a script in my maya/scripts folder that will do something similar to what you're describing.  This 'reload' script checks the current scene's name (which is its filename), then forces Maya to open it (which will unload the current scene first as part of that process).

 

reload.mel

//This script forces a reload of the current file
global proc reload()
{
string $file = `file -q -sceneName`;
file -f -o $file;
}
0 Likes

Anonymous
Not applicable

Hi, thanks for the reply.

 

Your script looks promising, but when I run it in Maya, nothing happens. I'm not really familiar with scripting in general, so I was wondering if I needed to insert or replace something in your script. 

 

Thank you!

0 Likes

mspeer
Consultant
Consultant

Hi!

To execute use simply:

reload;

All together here again:

global proc reload()
{
string $file = `file -q -sceneName`;
file -f -o $file;
}

//Execute by using
reload;
0 Likes

mspeer
Consultant
Consultant
Accepted solution

Hi!

A simpler version that may better fit your needs:

file -f -o `file -q -sceneName`;