zoukankan      html  css  js  c++  java
  • (转)单击一个物体,然后选择与它相同材质的所有物体。

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

     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) 
  • 相关阅读:
    iOS7,iOS8和iOS9的区别
    NSUrl
    什么是 MIME TYPE?
    TCP协议与UDP协议的区别
    KVC、KVO、NSNotification、delegate 总结及区别
    cocoapods 安装过程及常见问题
    素材丶资料
    方法 笔记(二)
    UIWebView UITextView
    在oj中Python的循环输入问题解决
  • 原文地址:https://www.cnblogs.com/3lina/p/10875384.html
Copyright © 2011-2022 走看看