Correct me if I’m wrong but I think I found a little bug.
- mGear version: 4.0.9, Maya version: 2022, OSX: Windows 10
For the sake of learning how to create custom components, I created a completely empty component that serves no purpose but just to be able to be built without any errors. And it works properly, except when I’m trying to edit its name. This is the error:
# Traceback (most recent call last):
# File "P:\Perforcelocal\[ws00]\PRJ_05\GAME\Tools\MayaTools\external\mGear\scripts\mgear\shifter\guide.py", line 1145, in updateComponentName
# guide.updateProperties(self.root, newName, newSide, newIndex)
# File "P:\Perforcelocal\[ws00]\PRJ_05\GAME\Tools\MayaTools\external\mGear\scripts\mgear\shifter\guide.py", line 1005, in updateProperties
# comp_guide.rename(root, newName, newSide, newIndex)
# File "P:\Perforcelocal\[ws00]\PRJ_05\GAME\Tools\MayaTools\external\mGear\scripts\mgear\shifter\component\guide.py", line 552, in rename
# self.parent, oldName, oldSideIndex)
# File "P:\Perforcelocal\[ws00]\PRJ_05\GAME\Tools\MayaTools\external\mGear\scripts\mgear\core\dag.py", line 250, in findComponentChildren3
# fullPath=True, type="transform"):
# TypeError: 'NoneType' object is not iterable
Looking at mGear’s code, this is the line that is triggering this error:
for item in cmds.listRelatives(node.name(), allDescendents=True, fullPath=True, type="transform"):
When testing the cmds.listRelatives() function myself I realize that when an object has no children, it doesn’t return an empty list ( [ ] ) , but a null object ( None )
And that’s what is triggering the error.
You can reproduce this bug by creating a control_01 component, deleting its only child (sizeRef), and trying to rename the component in the settings window.
This error will trigger too when trying to change the component’s side or index
Maybe it’s not an important bug because there is no reason to use an empty component that has no purpose, but I wanted to be sure that it is a bug in the mGear code and that I’m not missing something when trying to create custom components.