• (转)单击一个物体,然后选择与它相同材质的所有物体。


    单击一个物体,然后选择与它相同材质的所有物体。

     1 #-------------------------------
     2 # Select Objects By Material(s)   
     3 #-------------------------------
     4 # nerdocs - Just nerdy stuff that no one really cares about
     5 # https://paololazatin.com.com
     6 # created: 2015-02-19
     7 # last updated: 2016-03-18 - //output info to the bottom command line
     8  
     9 import maya.cmds as mC
    10 import maya.OpenMaya as oM
    11  
    12 messageOutput = "
    
    [nerdocs]: "
    13 objectsSelected = mC.ls(dag = True, o = True, s = True, sl = True)
    14  
    15 if objectsSelected == []:
    16     messageOutput +=  "No Objects Selected."
    17     oM.MGlobal.displayError(messageOutput)
    18 else:
    19     shadingGroups = mC.listConnections(objectsSelected,type='shadingEngine')
    20     selectionMaterial = mC.ls(mC.listConnections(shadingGroups),materials = True) 
    21  
    22     materialCount = 0
    23     previousMaterial = " "
    24     mC.select(clear = True)
    25     selected = mC.ls(sl = True)
    26  
    27     for object in selectionMaterial:
    28         if (previousMaterial != object):
    29             materialCount += 1
    30             previousMaterial = object
    31             mC.hyperShade(objects = object)
    32             selected += mC.ls(sl = True)
    33             mC.select(selected)
    34         
    35     messageOutput += str(len(selected)) + " object(s) selected based on the material of " + str(materialCount) + " selection(s)."
    36     oM.MGlobal.displayInfo(messageOutput) 
  • 相关阅读:
    互斥锁的通俗理解
    U-Boot下分区信息查看
    《计算机组成原理》唐朔飞第二版_笔记
    《大话程序员》安晓辉_笔记
    C++ 类对象的初始化顺序
    FilterTerminal使用说明全总结
    sed -i 命令常用方法总结
    入园记录
    cookies,sessionStorage 和 localStorage区别
    优雅降级和渐进增强的理解:
  • 原文地址:https://www.cnblogs.com/3lina/p/10875384.html
Copyright © 2020-2023  润新知