2014-12-05 105 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 

我知道了。