alembicTool_lsObject
来源:互联网 发布:有线路由器 知乎 编辑:程序博客网 时间:2024/06/05 06:40
import reimport maya.OpenMaya as OpenMayaimport maya.cmds as cmdsdef toMObject(*objects): sel = OpenMaya.MSelectionList() for i in objects: sel.add(i) out = list() for i in xrange(sel.length()): obj = OpenMaya.MObject() sel.getDependNode(i,obj) out.append(obj) return outdef tofullPath(*MObjects): return [OpenMaya.MFnDagNode(i).fullPathName() for i in MObjects]def clearRoots(roots): realRoots = cmds.ls(roots,long = True) roots = list() for i in xrange(len(realRoots)): n = True for r in xrange(len(roots)): if roots[r].startswith('%s|' % realRoots[i]): roots[r] = realRoots[i] n = False break elif realRoots[i].startswith(roots[r]): n = False break if n: roots.append(realRoots[i]) return rootsdef lsObject(roots,type = 'transform',filterName = None,fiterVisibility = True): ''' roots: root objects name (string list) type: (string list) filterName: (string list) fiterVisibility: if is True, only return the display is window Objects ''' if isinstance(filterName,basestring): filterName = [filterName] if not filterName: filterName = list() roots = clearRoots(roots) allDagNode = list() if type: for i in roots: nodes = cmds.listRelatives(i,allDescendents = True,fullPath = True,type = type) if nodes: allDagNode += nodes nodes = cmds.ls(i,long=True,type = type) if nodes: allDagNode += nodes else: for i in roots: nodes = cmds.listRelatives(i,allDescendents = True,fullPath = True) if nodes: allDagNode += nodes nodes = cmds.ls(i,long=True) if nodes: allDagNode += nodes if not filterName and not fiterVisibility: return allDagNode filterNode = list() if fiterVisibility: trf = cmds.listRelatives(roots,allDescendents = True,fullPath = True,type = 'transform') if trf: fiterVis = clearRoots([i for i in trf if not cmds.getAttr('%s.v' % i)]) for i in allDagNode: if all([not i.startswith('%s|' % f) and not i == f for f in fiterVis]): filterNode.append(i) allDagNode = filterNode if not filterName: return allDagNode filterNode = list() for i in allDagNode: for f in filterName: if re.match(r'.*%s.*' % f,i): filterNode.append(i) break return filterNodedef findSameName(*objects): name_dict = dict() for i in objects: long_name = cmds.ls(i,long=True)[0] name = long_name.rsplit('|',1) name[-1] = name[-1].split(':')[-1] long_name = '|'.join(name) if not name_dict.has_key(long_name): name_dict[long_name] = list() name_dict[long_name].append(i) return [name_dict[i] for i in name_dict if len(name_dict[i])>1]
0 0
- alembicTool_lsObject
- android设置全屏和横屏
- Maximum function nesting level of '100' reached, aborting!--漫谈递归:PHP里的尾递归及其优化
- S_ISREG S_ISDIR 等几个常见的宏
- 什么是代码缩进(code indent)
- BigDecimal的使用
- alembicTool_lsObject
- .NET 实验2-2
- 事件捕获和事件冒泡
- 三方库
- sql字符串拼接
- Android之NFC
- 13.Quartz2D
- React-开发工具
- org.apache.cxf.interceptor.Fault: The given SOAPAction ... does not match an operation