Initializing the Maya Environment in and for Python

Initializing the Maya Environment in and for Python

Maya runs any Python commands in the userSetup.py file whenever it starts up. You can use this file to set up your working environment or execute commonly used Python commands such as importing the maya.cmds module.

The userSetup.py script is executed during the initialization and setup phase of Maya; therefore, only commands which set up your working environment and have no dependencies on Maya functionality can be successfully run in this script.

NoteYou can use maya.utils.executeDeferred() to delay code execution until after the Maya scene is initialized. For more information, see maya.utils.
  1. Create a file named userSetup.py in the following folder:
    • Windows: <drive>:\Documents and Settings\<username>\My Documents\maya\<Version>\scripts
    • Mac OS X: ~/Library/Preferences/Autodesk/maya/<version>/scripts
    • Linux: ~/maya/<version>/scripts
  2. In the userSetup.py file, type the commands you want Maya to run on start up; for example, import maya.cmds as mc.
    NoteMake sure you save the file with the right extension (.py).

Python Computer Graphics Kit

http://cgkit.sourceforge.net/gallery.html

Introduction

The Python Computer Graphics Kit is an Open Source software package containing a collection of Python modules, plugins and utilities that are meant to be useful for any domain where you have to deal with 3D data of any kind, be it for visualization, creating photorealistic images, Virtual Reality or even games.

Currently, the entire kit consists of the following parts: