2014-12-05 1 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 
    ) 

이것은 쓰려고하는 기능입니다. 그러나 저는 현재 매트에 할당 된 폴리곤을 선택해야합니다. 내 질문은 :재질별로 폴리 쉬 선택 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 

는)

나는 그것을 얻었다.