Tank you for the explanation.

Yes I do agree to leave it like it is. But it striked me as odd.
A simple 'If parent is not none' check solved the problem.

Thank you again for the explanation. I'm starting to understand more and
more of the inner workings of pymel :)



2010/8/25 Paul Molodowitch <[email protected]>

> Well, first of all, comparing gui 'buttons' are not a direct / fair
> comparison to pymel commands, since they are almost always calling a mel
> script, which does some other stuff as well.
>
> For instance, in this case, it calls the 'Unparent' runtime command, which
> in turn calls scripts/others/performUnparent.mel
>
> A better comparison would be the maya.cmds.parent - which also throws an
> error in this situation:
>
> import maya.cmds
>
> cube = maya.cmds.polyCube()[0]
>
> maya.cmds.parent(cube, world = True)
>
>
> # Warning: Object, 'pCube1', skipped. It is already a child of the parent,
> 'world'. #
>
> # Error: Maya command error
>
> # Traceback (most recent call last):
>
> # File "<maya console>", line 3, in <module>
>
> # RuntimeError: Maya command error #
>
>
> However... having said that, I also tried the mel command (since it seemed
> odd that it would throw a warning AND an error), and that did NOT error - it
> only gave the warning.  So my guess is that there's an error in Autodesk's
> implementation of the python maya.cmds.parent cmd, which pymel relies on.
>
>
> Of course, it would be possible to make pymel behave like the mel command,
> and not throw an error in this situation.  However, I'm not sure it's clear
> in which manner it SHOULD behave in this case (ie, should it emulate the
> behavior of the python or mel command?)... so I'd lean towards leaving it
> the way it is, since that won't break anyone's existing code...
>
>
> - Paul
>
>
>
> On Wed, Aug 25, 2010 at 7:18 AM, Red <[email protected]> wrote:
>
>> Hello all,
>>
>> If I try to unparent an object but the object is already part of the
>> world then the following command results in an error:
>>
>> >> parent(anyObject, world = True)
>> # Error: Maya command error
>> # Traceback (most recent call last):
>> #   File "<maya console>", line 1, in <module>
>> #   File "C:\Program Files\Autodesk\Maya2011\Python\lib\site-packages
>> \pymel\internal\pmcmds.py", line 98, in wrappedCmd
>> #     res = new_cmd(*new_args, **new_kwargs)
>> # RuntimeError: Maya command error #
>>
>> However if I do the same from within maya with the unparent 'buton'
>> only get a warning message saying:
>>
>> # Warning: line 0: Object, 'myObject', skipped. It is already a child
>> of the parent, 'world'. #
>>
>> Is this just a bug within pymel ?
>> Or am I missing something here?
>>
>> Greets
>> Red
>>
>> --
>> http://groups.google.com/group/python_inside_maya
>
>
>  --
> http://groups.google.com/group/python_inside_maya
>

-- 
http://groups.google.com/group/python_inside_maya

Reply via email to