2014-12-05 124 views
0
-- this function selects polygons assigned to mat and assigns a matid of count 
    -- mat is the mat to select the polys by and count is the mat id to assign to the polys 

    function assignMatId mat count = (

     -- set the mat into meditMaterials in the second slot 
     meditMaterials[2] = mat 

     -- set the second slot to the active one 
     medit.SetActiveMtlSlot 2 true 

     -- select the polys assigned to mat 
     objarr = for obj in objects where obj.material == meditMaterials[medit.getActiveMtlSlot()] collect o 

     --assign selected polys a matid of count 
      --.. still writing this code 
    ) 

這是我正在嘗試編寫的功能。不過,我目前堅持選擇分配給墊的多邊形。 所以我的問題是:按材質選擇Polys maxscript

我將如何給予一個選定的材料(在meditMaterials中的activeSlot)選擇分配給它們的材料的所有聚合物。可能有多個物體分配給物體,因此它還需要選擇其他可編輯的多物體。

想從哪裏開始?

回答

1
function assignMatId mat count = (

    --collect all of our objects that are editable polys 
    objs = for x in $* where classOf x == PolyMeshObject collect x 

    -- collect all of our objects where the material is the same as the mat 
    objarr = for obj in objs where obj.material == mat collect obj 

    -- go through and assign the correct mat id 
    for obj in objarr do polyop.setFaceMatID obj #{1..obj.numfaces} count 

我知道了。