Community
Maya Forum
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MEL command to open current scene without saving

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
1610 Views, 4 Replies

MEL command to open current scene without saving

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!

4 REPLIES 4
Message 2 of 5
tkaap2
in reply to: Anonymous

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;
}
Message 3 of 5
Anonymous
in reply to: tkaap2

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!

Message 4 of 5
mspeer
in reply to: Anonymous

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;
Message 5 of 5
mspeer
in reply to: Anonymous

Hi!

A simpler version that may better fit your needs:

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report