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
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]
PS: I personally use a chrome plugin called “Markdown here” to do my code formatting..
--
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 python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/45b11971-1940-b071-496f-a07d3d0409a6%40web.de.
For more options, visit https://groups.google.com/d/optout.
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/8566d197-3cab-120a-bf93-cd0d977afbdd%40web.de.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/45b11971-1940-b071-496f-a07d3d0409a6%40web.de.
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 python_inside_maya+unsub...@googlegroups.com.
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.--
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 python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/8566d197-3cab-120a-bf93-cd0d977afbdd%40web.de.
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 view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAAssL7b0NFJSpMxS%3Dc%3Dya8CgyBZdEJ3ZpS%3DioyY%3D8yUZRujM5w%40mail.gmail.com.To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
I'm not sure if this will help but I use the flatten flag in the mel command ls.
pm.ls(sl=1, fl=1)This will return a list of selected components flattened.
I believe sets also has a flatten flag that you can use to flatten components.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAJAkR62PygEnZvNOLHDxi1UBtMzf6CRhV3tm%2BEiaUS5QeG5okg%40mail.gmail.com.