This is my outliner, eg. '|hie1|cube1' and 'cube2'
If I select cube1 and did:
cmds.parent("|hie1|cube1", world=True)
This will unparent my cube1 out of hie1 and into 'world' level? Sorry, can't think of a better term.
But if I did the same thing to cube2:
cmds.parent("cube2", world=True)
I will get an error:
# Warning: Object, 'cube2', skipped. It is already a child of the parent, 'world'. #
# Error: Maya command error
# Traceback (most recent call last):
# File "<maya console>", line 2, in <module>
# RuntimeError: Maya command error #
Even as I used `try...except...` it does not stops my tool function but you can explicitly see in the status line that there is a quick flash of red color before it disappears.
Is there any command that enables me to check if the object is already in 'world' or better ways to get around this problem?