创建小球和用mel列举它们的shape 用时2秒56
for($i=0;$i<10000;$i++){
polySphere;
}
string $sel[] = `ls -typ "mesh"` ;
for($sph in $sel){
print ($sph+"\n");
}
用cmd api列举它们 用时分别为3秒88 3秒49
import maya.cmds as mc
sel = mc.ls(typ = 'mesh')
for sph in sel:
print sph+'\n'
import maya.OpenMaya as OM
import pymel.core as pm
sel = pm.ls(typ = 'mesh')
sphere_api_list = OM.MSelectionList()
for pyNode in sel:
sphere_api_node = pyNode.__apiobject__()
sphere_api_list.add(sphere_api_node)
sphere_mit_list = OM.MItSelectionList(sphere_api_list)
temp_dag_path = OM.MDagPath()
while not sphere_mit_list.isDone():
sphere_mit_list.getDagPath(temp_dag_path)
print temp_dag_path.partialPathName()
sphere_mit_list.next()