Как узнать какие материалы назначены на выделенный объект?
Код:
string $lmxListAssignMaterials[];
$lmxObjectShape = `listRelatives -shapes`;
$lmxListSG = `listConnections -source 0 -destination 1 -type "shadingEngine" $lmxObjectShape`;
$lmxSizeListSG = `size($lmxListSG)`;
for ($i=0; $i<$lmxSizeListSG; $i++) {
$lmxConnectToSG = `listConnections ($lmxListSG[$i]+".surfaceShader") ($lmxListSG[$i]+".miMaterialShader")`;
$lmxListAssignMaterials[$i] = $lmxConnectToSG[0];
}
print($lmxListAssignMaterials)
Код:
import maya.cmds as mc
lmxObjectShape = mc.listRelatives(shapes=True)
lmxListSG = mc.listConnections(lmxObjectShape, source=False, destination=True, type='shadingEngine')
lmxSizeListSG = len(lmxListSG)
lmxListAssignMaterials=[]
for i in range(lmxSizeListSG):
lmxConnectToSG = mc.listConnections((lmxListSG[i]+".surfaceShader"), (lmxListSG[i]+".miMaterialShader"))
lmxListAssignMaterials.insert(i,lmxConnectToSG)
print(lmxListAssignMaterials)
Последнее редактирование: