You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current (pymel) implementation is really slow when doing connection traversal.
I've done some quick benchmarks and OpenMaya2 seem the faster for this.
# Benchmark cmds vs OpenMaya vs OpenMaya2
# For each attr of each nodes, get the name of each connected attrs
import time
import pymel.core as pymel
from maya import OpenMaya
from maya.api import OpenMaya as om2
all_ = []
objs = pymel.ls()
print("Scanning {0} nodes".format(len(objs)))
st = time.time()
for obj in objs:
for attr in obj.listAttr():
all_.append(attr.name())
et = time.time()
print("Pymel took: {0}".format(et-st))
###
# Benchmark cmds vs OpenMaya vs OpenMaya2
# For each attr of each nodes, get the name of each connected attrs
import time
all_ = []
mfns = [obj.__apimfn__() for obj in pymel.ls()]
print("Scanning {0} nodes".format(len(mfns)))
st = time.time()
for mfn in mfns:
for i in xrange(mfn.attributeCount()):
a = mfn.attribute(i)
amfn = OpenMaya.MFnAttribute(a)
all_.append(amfn.name())
et = time.time()
print("OpenMaya took: {0}".format(et-st))
###
pymel.select(pymel.ls())
sel = om2.MGlobal.getActiveSelectionList()
all_ = []
print("Scanning {0} nodes".format(sel.length()))
st = time.time()
for i in xrange(sel.length()):
mfn = om2.MFnDependencyNode(sel.getDependNode(i))
for j in xrange(mfn.attributeCount()):
a = mfn.attribute(j)
amfn = om2.MFnAttribute(a)
all_.append(amfn.name)
et = time.time()
print("OpenMaya2 took: {0}".format(et-st))
Current (pymel) implementation is really slow when doing connection traversal.
I've done some quick benchmarks and OpenMaya2 seem the faster for this.
Result in:
The text was updated successfully, but these errors were encountered: