Don't know off hand, but likely it's because pymel is wrapping MFnSet...
sometimes the API commands give slightly different results than the
maya.cmds equivalents

On Fri, Nov 24, 2017 at 6:28 AM Felix Ulber <[email protected]> wrote:

> Thanks Paul! Very informative.
>
> Just for personal interest - is there any particular reason why using
> sets(q) and ObjectSet.members() give different results? I tried to
> understand it from the pymel source code but got stucked.
>
> best
> Felix
>
>
> Am 17.11.2017 um 23:57 schrieb Paul Molodowitch:
>
> I should note that, going forward, adding the two component objects
> directly is probably the preferred way of doing things, as it will use the
> underlying API objects, and should be considerably faster for large
> component selections.
>
> On Fri, Nov 17, 2017 at 2:55 PM Paul Molodowitch <[email protected]>
> wrote:
>
>> Hi - so, currently, I think the only way to combine two component objs
>> would be to just create a new object with their indices, ie:
>>
>> sel = [pm.PyNode('myCube.f[0:2]'), pm.PyNode('myCube.f[4]')
>> indices = itertools.chain.from_iterable(x.indicesIter() for x in sel)
>> indices = list(indices)
>>
>> singleComp = pm.PyNode('myCube').f[indices]
>>
>> Note that you have to cast the iterator to a list for current pymel
>> releases. However, I just pushed a change to the github repo (
>> https://github.com/LumaPictures/pymel) which will fix this, and allow
>> you to pass an iterator in as the indices for a new component object.
>>
>> I also added in the ability to add two component objects, so you could
>> just do:
>>
>> pm.PyNode('myCube').f[0:2] + pm.PyNode('myCube.f[4]')
>>
>> or
>>
>> faces = pm.PyNode('myCube').f[0:2]
>> faces += pm.PyNode('myCube.f[4]')
>>
>> With my latest changes, you can also do:
>>
>> faces = pm.PyNode('myCube').f[0:2, 4]
>>
>>
>>    - Paul
>>
>> PS: I personally use a chrome plugin called “Markdown here”
>> <http://markdown-here.com/> to do my code formatting..
>>
>> On Fri, Nov 17, 2017 at 3:52 AM Felix Ulber <[email protected]> wrote:
>>
>>> Hey List :)
>>>
>>> I am struggeling in the process of handling lists of mesh components
>>> (mesh faces, from shadingGroups, per-face material assignment).
>>> Using PyMEL, there are two ways to query:
>>>
>>> sets(shadingGroup, q = True)
>>>
>>> returns:
>>>
>>> [MeshFace(u'pSphereShape1.f[0:6]'),
>>>  MeshFace(u'pSphereShape1.f[17:26]'),
>>>  MeshFace(u'pSphereShape1.f[37:46]'),
>>> ...]
>>>
>>> whereas
>>>
>>> shadingGroup.members()
>>>
>>> gives me:
>>>
>>> [MeshFace(u'pSphereShape1.f[0:6,17:26,37:46,57:66,77:86,...]')]
>>>
>>> Which is more what I need. But in this case, I cannot use the PyMEL OO
>>> variant, for  in case of quering a shadingGroups it under certain
>>> circumstances the result contains the shaderBallGeom object (from the
>>> hyperShade material preview).
>>>
>>> So I need a way to convert the multiple MeshFace objects into one, i.e.
>>> the second kind of representation.
>>>
>>> I rember long time ago, in mel there was something, i think in the use
>>> of certain commands, to convert the representation of sparse component
>>> lists - its just that I did not have to work with this for so long I just
>>> cannont remember it.
>>>
>>> I tried to look up the internals of the PyMEL "ObjectSet" members method
>>> but also failed :(
>>>
>>> Seems like a rather simple thing, sorry, I'm just a blockhead right
>>> now...
>>>
>>> BTW: how do you format/beautify your code for mailing it here?
>>>
>>> Thanks
>>> Felix
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Python Programming for Autodesk Maya" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/45b11971-1940-b071-496f-a07d3d0409a6%40web.de
>>> <https://groups.google.com/d/msgid/python_inside_maya/45b11971-1940-b071-496f-a07d3d0409a6%40web.de?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> ​
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
>
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAAssL7ZmRL6Fe4-W_UGnTuB53uH-LFJks4wVeUaVw%3DxhdbFutg%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAAssL7ZmRL6Fe4-W_UGnTuB53uH-LFJks4wVeUaVw%3DxhdbFutg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
>
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/8566d197-3cab-120a-bf93-cd0d977afbdd%40web.de
> <https://groups.google.com/d/msgid/python_inside_maya/8566d197-3cab-120a-bf93-cd0d977afbdd%40web.de?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAAssL7b0NFJSpMxS%3Dc%3Dya8CgyBZdEJ3ZpS%3DioyY%3D8yUZRujM5w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to