cmdx: cmdx.listRelatives always returns None

Steps to reproduce:

  1. Create cube primitive.
  2. run `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

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 18 (18 by maintainers)

Most upvoted comments

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 access["attributes"]. I tried finding a way around it, but there doesn’t seem to be one? 🤔

With that in mind, it would be safe to expand on __repr__ to return more info.

Hm, I remember going back and forth on this. It’s possible that if you pass a cmdx.DagNode to a maya.cmds command, that Maya would treat it as a string via repr. It’s worth a shot though, the tests should cover any backwards compatibility issues. You can try this locally already, and run the tests locally. If those pass, I see no reason why not. Nobody would be surprised by repr returning too much information I think.