Python Notes
Last edited May 1, 2008
More by daxx2k »

Comune di Sant'Ilario d'Enza
www.comune.santilariodenza.re.it/
Articles

Some thoughts on Python in Maya

 Mike Junta talking about python in maya.
Labels: Python Articles
Tutorials

Modules

WxPython
http://www.wxpython.org/
 a good module to create standard interface with the style of the system where running

Labels: Python Modules
PyOpenGL
http://pyopengl.sourceforge.net/
 The Python OpenGL® Binding
Labels: Python Modules
pyGame
http://www.pygame.org/news.html
 a game interface for python
Labels: Python Modules
python CGKIT
http://cgkit.sourceforge.net/
this module give the access to Renderman , SL , CGshaders and more on CG
Labels: Python Modules
MySqlDb
http://sourceforge.net/projects/mysql-python
 THE module to interface python with mySQL
Labels: Python Modules
Python 3D Software links
www.vrplumber.com/py3d.py#PyOpenGL
 
 This is a section to put notes about python modules
Labels: Python Modules
Notes

Useful links

http://www.python.org - The Python home page

http://diveintopython.org - A really good programmers' guide to Python

http://it.diveintopython.org/toc/index.html (italian doc)

http://docs.python.org/ref/ref.html - Python Reference Manual

http://docs.python.org/lib/lib.html - Python Library Reference

http://www.penzilla.net/tutorials/python/

http://www.effbot.org/librarybook (the eff-bot guide to) The Standard Python Library

http://docs.python.it  (italian doc) e - zona Python

http://aspn.activestate.com/ASPN/Cookbook/Python (en doc)

http://www.pycode.com/

This is a section to put useful links to python docs

Labels: Python Notes
Code Examples

http://www.koders.com/                  a nice bank of open sources c++ / python files  
import maya.cmds as cmds
class testW:
butts=["uno","due","tre","quattro","cinque","sei"]
def gui(self):
w=cmds.window("testwin")
c=cmds.columnLayout(adj=True)
self.doButtons(c)
cmds.showWindow(w)

def doButtons(self,parentC):
def runCbut(arg1):
return lambda x: self.bCommand(arg1)

for b in self.butts:
cmds.button(b,c=runCbut(b),parent=parentC)

def bCommand(self,txt):
oldName=txt+"_firstTime"
newName=txt+"_renamed"
if cmds.objExists(oldName):
cmds.rename(oldName,newName)
else:
cmds.sphere(n=oldName)

ww=testW()
ww.gui()
 
 
this is a simple example that show how to use python to build maya interfaces
with lambda (to defer the evaluation)
Labels: Python Source Codes
import maya.cmds as mc

def mainScriptMethod():
    #Check to see if the window exists
    if mc.window("mainScriptMethodWindow", q=True, ex=True):
    mc.deleteUI("mainScriptMethodWindow")

Note that in MEL, this is much more direct and clear:

if (`window -q -ex mainScriptMethodWindow`) {
// Do something
}
 

In Python: selectedObjects = mc.ls(sl=True)
In MEL: string $selectedObjects[] = `ls -sl`;
to import module from  sub folder just put a __init__.py file into the folder
example:

----------------------------------
mainScript.py

folder
       |
    __init__.py
    themodule.py
----------------------------------

into the script use this syntax to import the module
import folder.themodule.py
Labels: Python Notes
interesting blob about python
 
Maya Python API

/opt/aw/maya8.5.1/devkit/plug-ins/scripted
 location of all the Python scripted plugins for Maya
Labels: Python Source Codes
Books

Python Essential Reference - Google Book
books.google.co.uk/books?id=kQom0WiUbZQC
The content on this page is provided by a Google Notebook user, and Google assumes no responsibility for this content.