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

Как бы я выбрал выбранный материал (activeSlot в meditMaterials), выберите все полисы с этим назначенным им материалом. Может быть несколько объектов, которым назначен материал, поэтому ему нужно также выбрать другие редактируемые поли объекты.

Любые мысли о том, с чего начать?

ответ

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 

)

Я получил его.

Смежные вопросы