-
Notifications
You must be signed in to change notification settings - Fork 36
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
cmdx.listRelatives always returns None #20
Comments
Thanks for reporting this @fvbehr, are you able to spot what's going on? |
No, I am afraid that debugging this is beyond my skill level. |
For the time being, you can do: list(cmdx.encode("pCube1").descendents()) For hierarchy, or any of the other options here. |
Could it be that for |
Testsetup:
It looks like cmdx always returns None. No mater what flags are used. |
The |
I think I see the problem.
It's expecting a cmdx.listRelatives(cmdx.encode("pCube1")) Normally, all commands from if isinstance(node, str):
node = encode(node) That would handle the conversion automatically and internally. What do you think? |
I would prefer if it would mimic Maya's cmds. I added the if statement to listRelatives.
So its not returning the same as cmds. What values can I pass as the type argument? It expects an int. All values except 0 seem to return an empty list. |
It's expecting an cmdx type, like The reason for not taking a string like
It's actually returning a |
Right. I missed that. My bad. |
If you'd like, it would be great with a PR containing the changes you'd like to see added, then we can chat about specifics from there and also ensure the tests are all happy (performance included). |
Will do. |
yoink 🙂 |
@mottosso another small change I think could help with this issue is to instead of
That way the user will know right off the bat that the returned value from a Of course, they could still get the |
Hm, I remember going back and forth on this. It's possible that if you pass a |
That is a good point. It wouldn’t be ideal to have this functionality lost. I’ll see what I can do and make a PR or just comment what I find out here. |
I tested the following here (on the node = cmdx.createNode("transform")
cmds.ls(node)
# Error: TypeError: file <maya console> line 1: Object |transform1 is invalid #
cmds.addAttr(node, ln='test')
# Error: TypeError: file <maya console> line 1: Object |transform1 is invalid # However, the following works, since the node does exist. cmds.ls(str(node))
# Result: ['transform1'] #
cmds.ls(repr(node))
# Result: ['transform1'] #
cmds.addAttr(repr(node), ln='test')
cmds.objExists(repr(node) + '.test')
# Result: True # Does the same happen there on your end? I can't tell exactly why this happens, since class MyClassRepr(object):
def __init__(self, name):
self.name = name
def __repr__(self):
return self.name
class MyClassStr(object):
def __init__(self, name):
self.name = name
def __str__(self):
return self.name cmdx.createNode('transform')
# Result: |transform1 #
test_repr = MyClassRepr('transform1')
type(test_repr)
# Result: <class '__main__.MyClassRepr'> #
test_str = MyClassStr('transform1')
type(test_str)
# Result: <class '__main__.MyClassStr'> #
cmds.ls(test_repr)
# Result: ['transform1'] #
cmds.ls(test_str)
# Result: ['transform1'] # Of course this is a lot simpler, but it is unclear to me why it wouldn't work with |
That was interesting, I manage to figure out that this is what's causing it to fail. class MyClassStr(object):
def __init__(self, name):
self.name = name
def __str__(self):
return self.name
def __getitem__(self, key):
return True
node = MyClassStr("multMatrix1")
cmds.ls(node)
# # TypeError: Object multMatrix1 is invalid This is what we use to With that in mind, it would be safe to expand on |
Steps to reproduce:
`import cmdx
import maya.cmds as cmds
print cmdx.listRelatives("pCube1")
print cmds.listRelatives("pCube1")`
cmds.listRelatives returns [u'pCubeShape1'] while
cmdx.listRelatives("pCube1") returns None
Example from the command reference also returns false and not true.
cmdx 0.4.6
Maya 2020.2
Windows 10
The text was updated successfully, but these errors were encountered: