Unless there's a reason why the mel function doesn't fit your needs (ie, it
doesn't return unique names, or you need to customize it in some way), or
you're using it as a learning exercise, I'd advise just using the mel.
 Whether it's "dirty" is a matter of opinion, but using mel in python is
something you'll have to get used to.  A lot of maya is built on mel, and I
don't see that changing anytime soon; and as long as that is the case, there
will always be situations where you'll need to call out to mel scripts.
If you're worried about things looking untidy, pymel can handle some of the
string processing to make mel functions seem more pythonic:

import pymel.core as pm
res = pm.mel.findRelatedSkinCluster()

That's a pretty simplistic example, since there's no args, but it will also
automatically convert args, keyword args, lists, and other things - see the
docs for more info:

http://www.luma-pictures.com/tools/pymel/docs/1.0/generated/classes/pymel.core.language/pymel.core.language.Mel.html#pymel.core.language.Mel

<http://www.luma-pictures.com/tools/pymel/docs/1.0/generated/classes/pymel.core.language/pymel.core.language.Mel.html#pymel.core.language.Mel>Of
course, under the hood, it's still doing string processing, then calling
mel.eval, so the 'dirtiness' is still there; it's just sort of swept under
the carpet. =)

- Paul

PS - Oh, and if you need access to mel global variables, there's also a
melGlobals dictionary-like object:

http://www.luma-pictures.com/tools/pymel/docs/1.0/generated/classes/pymel.core.language/pymel.core.language.MelGlobals.html#pymel.core.language.MelGlobals

On Wed, Feb 2, 2011 at 11:40 PM, Ted Charlton <[email protected]>wrote:

> little weak...
>
>
> shps = mc_.listRelatives(s=True, ni=True)
> for sh in shps:
>     scs = mc_.ls(type='skinCluster')
>     for sc in scs:
>         mesh = mc_.skinCluster(sc, q=True, g=True)
>         if mesh[0] == sh:
>             relatedSkinCluster = sc
>             print relatedSkinCluster
>
> Better.
>
>
> On Wed, Feb 2, 2011 at 11:36 PM, Ted Charlton <[email protected]>wrote:
>
>> shps = mc_.listRelatives(s=True, ni=True)
>> for sh in shps:
>>     scs = mc_.ls(type='skinCluster')
>>     for sc in scs:
>>         mesh = mc_.skinCluster(sc, q=True, g=True)
>>         if mesh[0] == shps[0]:
>>             relatedSkinCluster = sc
>>             print relatedSkinCluster
>>
>> GVOK,
>>
>> Maybe this can help.
>> Cheers.
>>
>>
>> On Wed, Feb 2, 2011 at 10:52 PM, Gerard van Ommen Kloeke <
>> [email protected]> wrote:
>>
>>>  I'll probably go that route due to time and experience, but I will write
>>> something in py eventually (and post)
>>> Thanks for the help
>>>
>>> You can run mel from python:
>>> import maya.mel as mel
>>> mel.eval('findRelatedSkinCluster '+name_of_mesh)
>>>
>>> On Thu, Feb 3, 2011 at 9:41 AM, GerardVOK <[email protected]> wrote:
>>>
>>>> Hi. I am looking for a way to determine the skinCluster that is
>>>> related to a mesh. Maya came with a "findRelatedSkinCluster" mel
>>>> script, but doesnt have this as a py script. I will end up writing my
>>>> own procedure but unlike my Mel experience, I am very new to python
>>>> and this will take some time. I guess I could always run the mel
>>>> script in the python script but that just seems dirty..
>>>>
>>>> If there is anyone out there who may have a solution, I would
>>>> appreciate your help.
>>>>
>>>> Thanks
>>>> Gerard Van Ommen
>>>> Australia
>>>>
>>>> --
>>>> http://groups.google.com/group/python_inside_maya
>>>>
>>>
>>>  --
>>> http://groups.google.com/group/python_inside_maya
>>>
>>>
>>>  --
>>> 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