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
import sys
you probably don't know just yet what functions you can call. You can get python to show you this with dir:
dir(sys)
# Result: ['big list of things', 'stuff','blah'...]
dir(sys)
# Result: ['big list of things', 'stuff','blah'...]
If you need more help, use help:
help(sys)
# ...big user friendly(ish) help documentation gets printed
help(sys)
# ...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
dir(foo)
# Result: ['lots', 'of','things']
from pymel.core import *
foo = SCENE.polySphere1
dir(foo)
# 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:
foo.listAttr()
Result: [Attribute(u'polySphere1.message'),
Attribute(u'polySphere1.caching'),
Attribute(u'polySphere1.blah'),
etc.. ]
foo.listAttr()
Result: [Attribute(u'polySphere1.message'),
Attribute(u'polySphere1.caching'),
Attribute(u'polySphere1.blah'),
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(foo)
# Help on PolySphere in mdile pymel.core.nodetypes:
# nt.PolySphere(u'polySphere1')
help(foo)
# 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.