Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation of Attribute hierarchies doesn't always work (tested in Maya 2022.2) #459

Open
fxs-jstewart opened this issue Aug 10, 2022 · 1 comment

Comments

@fxs-jstewart
Copy link

Below is an example that fails.

I expect this probably has something to do with the interaction of multi and array attributes, and probably generalizes. But I've only actually tested it as encountered on constraints.

This was tested in Maya 2022.2, but I don't think it's a recent development.
IIRC I've encountered it a few years ago.

# create two cubes
a, _ = pm.polyCube(name='a')
b, _ = pm.polyCube(name='b')

# offset the first one
a.t.set(1, 2, 3)
a.r.set(30, 60, 90)

# constrain the other, with offset
c = pm.parentConstraint(a, b, mo=True, name='c')


# now attempt to navigate the Attribute hierarchy of the constraint node
# the objective will be to get an Attribute object representing c.target[0].targetOffsetRotateX

# we can get there fine by giving PyNode the full path
attrPath = c.name() + '.' + testAttr.longName()
print(attrPath)  # c.target[0].targetOffsetRotateX

attr = pm.PyNode(attrPath)  # Result: Attribute('c.target[0].targetOffsetRotateX') # 
print(attr)  # c.target[0].targetOffsetRotateX


# we can also get there by querying the child list of the targetOffsetRotate attribute
assert c.target[0].targetOffsetRotate.children()[0] == pm.PyNode('c.target[0].targetOffsetRotateX')  # Succeeds.

# but if we attempt to navigate using the long name of the child attribute, pymel returns the wrong result.
assert c.target[0].targetOffsetRotateX == pm.PyNode('c.target[0].targetOffsetRotateX')  # AssertionError!

print(c.target[0].targetOffsetRotateX)
# c.target[0]

assert c.target[0].targetOffsetRotateX != c.target[0]  # AssertionError!
@fxs-jstewart
Copy link
Author

also, in the context of the example above:

print(pm.PyNode('c').attr('target[0].targetOffsetRotateX'))
# c.target[0]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant