15 Oct 2012

Nested Attributes

If you want to create nested attributes you need to take care of unique attribute names, because you can call it from the root. When you want to create an attribute with the existed name you will get an error. I had this problem when I created a really deep coumpound attribute.

In the example the sphere is a pymel object.

WRONG attribute concept name:
sphere.position.X

CORRECT attribute concept name:
sphere.position.positionX

Calling:
sphere.positionX

# =======================================================
import pymel.core as pc
plane = pc.polyPlane()[0]
plane.addAttr('sphere0', at='float3')
plane.addAttr('sphere0pos', at='float', p='sphere0')
plane.addAttr('sphere0rot', at='float', p='sphere0')
plane.addAttr('sphere0scl', at='float', p='sphere0')
# =======================================================

No comments:

Post a Comment