From cgwiki
Jump to: navigation, search

07 - learning with dir, help, webpages

If you import a python module, say the builtin module that helps you do things with the system:

import sys

you probably don't know just yet what functions you can call. You can get python to show you this with dir:

# Result: ['big list of things', 'stuff','blah'...]

If you need more help, use help:

# ...big user friendly(ish) help documentation gets printed

To a certain extent, pymel objects work in a similar fashion:

from pymel.core import *
foo = SCENE.polySphere1

# Result: ['lots', 'of','things']

I say 'certain extent', as pymel mixes in lots of calls and things that aren't directly related to the object. Still, there's stuff there.

If you look closer, you'll see lots of setBlah and getBlah calls, these are the 'official' ways of setting attributes.

Another way is to list the attributes directly:

Result: [Attribute(u'polySphere1.message'), 
         etc.. ]

From that list you can see the basic attrs you'd be interested in like radius, subdivisionsHeight and whatnot.

The built-in help with pymel is less awesome:

# Help on PolySphere in mdile pymel.core.nodetypes:

# nt.PolySphere(u'polySphere1')

Thanks pymel. If you hit google with a phrase like 'pymel polySphere', you'll probably find what you need.