按材质maxscript选择Polys

时间:2014-12-05 07:14:29

标签: 3dsmax maxscript

    -- 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
    )

这是我正在尝试写的功能。但是我目前仍然坚持选择分配给mat的多边形。 所以我的问题是:

我如何选择所选材料(meditMaterials中的activeSlot)选择分配给它们的所有材料。材质可能有多个对象,因此需要选择其他可编辑的多边形对象。

关于从哪里开始的任何想法?

1 个答案:

答案 0 :(得分: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

我明白了。