-- 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
)
This is the function I'm trying to write. However I'm currently stuck on the select the polys assigned to mat.
So my question is:
How would I given a selected material (activeSlot in meditMaterials) select all the polys with that material assigned to them. There may be multiple objects the material is assigned to, so it needs to select into other editable poly objects as well.
Any thoughts on where to start?
Replies
If you just want to get objects that have the currently selected mat in the medit, you just need that
function assignMatId count = ( objarr = for obj in objects where obj.material == meditMaterials[medit.getActiveMtlSlot()] collect obj --considering objects are editable poly... for obj in objarr do polyop.setFaceMatID obj #{1..obj.numfaces} count )if you already know the mat, you just need thatfunction assignMatId mat count = ( objarr = for obj in objects where obj.material == mat collect obj --considering objects are editable poly... for obj in objarr do polyop.setFaceMatID obj #{1..obj.numfaces} count )