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/CAAssL7Yh9dgO_T2YmWxke3Qep8OB2MpTnSLQNAy%3DM_gh8g7FSQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.