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: 

Easy way of saving python script?

1 REPLY 1
Reply
Message 1 of 2
Yunni
1557 Views, 1 Reply

Easy way of saving python script?

I want to save my python scripts with a hotkey/shortcut, preferably Ctrl+S, to a set directory with it's filename. So if the file is called myFile.py and I hit Ctrl+S, the script will automatically be saved to desktop/myFile.py, without any prompts. Just like a normal text editor handles files. Is this possible within Maya? Would save sooooooooo much time when scripting.

 

Thanks!

1 REPLY 1
Message 2 of 2
TechToast
in reply to: Yunni

I assume you are talking about scripts loaded into the script editor? The problem with what you want is that the script editor doesn't hold any links to actual files. When you open a script in the script editor, all it does is to load the content of the file, but doen't keep any file handles active. So its not as simple as just hitting 'Save'

 

However why don't you just use a text editor to work on your scripts and then simply import them into Maya to run them...that way you can just rely on your text editor to handle the CTRL+S stuff.

 

So for example, save this python script to your MAYA_SCRIPT_PATH somewhere (e.g. /My Documents/maya/scripts/testPythonScript.py):

 

# Example python script called testPythonScript.py
import maya.cmds as cmds
print 'This is my Python Script'
cmds.polyCube();

 

Then run these lines in Maya:

 

import testPythonScript
reload (testPythonScript)
testPythonScript

 

Now all you have to do is edit the python script in any text editor, save the file normally and re-run the red lines above. I usually make a shelf button out of these lines to speed up my workflow meaning I don't even need the script editor open if I dont want it.

 

Hope this helps

 

Mike

 

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

Post to forums  

Autodesk Design & Make Report