How to change next code to object-oriented Pymel ?
from pymel.all import *
FacesList = ls((polyListComponentConversion((ls(fl=1,sl=1)), tf=1)), fl=1)
thanks in advance
How to change next code to object-oriented Pymel ?
from pymel.all import *
FacesList = ls((polyListComponentConversion((ls(fl=1,sl=1)), tf=1)), fl=1)
thanks in advance
if you’re trying to get back a MeshFace object, you can do:
import pymel.core as pm
# if you know the objects name, say pCube1
faces = pm.PyNode('pCube1.f[li]')[/li]
# or
faces = pm.MeshFace('pCube1.f[li]')[/li]
# from a selection
my_node = pm.ls(sl=True)[0] # or whatever index you want i guess
faces = my_node.f
# shortcut
faces = pm.ls(sl=True)[0].f
# you can also access the faces directly for operations, ie:
# get the connected edges for each face
for the_face in my_node.f:
print(the_face.connectedEdges())
Hope that helps!
[QUOTE=djTomServo;7842]if you’re trying to get back a MeshFace object, you can do…[/QUOTE]
What about if we have selected a few of the object or face?
There should be variation in the choice of.
pymel.ls() returns a list of MeshFace objects if you have faces selected, even across different objects. This can create some weird returns, ideally you’d want one MeshFace for your whole selection (should log that as a sug). if you have different objects selected, you can still access faces through the .f interface per object.
OK, thanks for the explanation