Hi,

First things first, in API you need to understand difference between attribute and plug. Attribute is like a data description - it does not hold data. Think of it as a "description of database field": it defines data type, default value, is it stored or not, array or not, etc. Attribute also defines it's parent attributes.

To actually get data, you need to access plugs. Plugs are what actually hold data values. *What* data a plug holds, is described by an attribute - every plug has one associated to him.

So when accessing values in your node, you have two options. If you know the attribute MObject beforehand, this will slightly speed up things for you, as you go directly:

from maya import OpenMaya as om
plug = om.MPlug(yourNodeMObject,yourAttributeMObject)
value = plug.asFloat()

if you don't own attribute handle beforehand, you'll need to find the attribute by string:

nodeFn = om.MFnDependencyNode(yourNodeMObject)
plug = nodeFn.findPlug("yourAttributeName")
value = plug.asFloat()

hope this helps, cheers.


On 2010.10.20 01:59, Alexander Mirgorodsky wrote:
How I can get my custom attribute by Python API
something like this way in scripts:

myAttrValue = mc.getAttr('defaultRenderGlobals.myCustomAttribute') ?

--
Viktoras
www.neglostyti.com

--
http://groups.google.com/group/python_inside_maya

Reply via email to