[PYTHON] First Maya script introduction
Introduction
Now that we've created a handy script for Maya, make a note of the steps to get started.
procedure
Prepare a test script
Prepare the following sample file.
- Of course, if you already have a script, omit it.
helloWorld.py
# -*- coding: utf-8 -*-
def main()
print u'hello hello'
Script storage
You can call it on Maya by placing the script in the directory below.
- Priority order (when scripts with the same function name are mixed in multiple directories, the one above has priority)
Maya 2015
Mac
-/ Users / / Library / Preferences / Autodesk / maya / 2015-x64 / ja_JP / scripts
-/ Users / / Library / Preferences / Autodesk / maya / scripts
-/ Users / / Library / Preferences / Autodesk / maya / 2015-x64 / ja_JP / prefs / scripts
Maya 2016
Mac
-/ Users / / Library / Preferences / Autodesk / maya / 2016 / ja_JP / scripts
-/ Users / / Library / Preferences / Autodesk / maya / scripts
-/ Users / / Library / Preferences / Autodesk / maya / 2016 / ja_JP / prefs / scripts
Maya 2017
Mac
-/ Users / / Library / Preferences / Autodesk / maya / 2017 / ja_JP / scripts
-/ Users / / Library / Preferences / Autodesk / maya / scripts
-/ Users / / Library / Preferences / Autodesk / maya / 2017 / ja_JP / prefs / scripts
Try to run
-
Press the icon at the bottom right of the screen to start the "script editor".
-
Enter the command in the area under the displayed "Script Editor" and press "Ctrl + Enter" to execute the process.
import helloWorld
helloWorld.main()
-
The result of the command is output in the upper area.

Create shortcut
After selecting the code to put on the shelf, hold down the middle mouse button and drag and drop it toward ② to create a shortcut.
After that, all you have to do is press the shortcut on the shelf.
