Notifications
Clear all

[Closed] Set material ID to 1

 em3

Hey all!
I have this little script I am running and I am trying to set the materialID of the poly to “1” At the moment this get’s me to where I can set it but I have to set it manually.

Can someone help me out here?

Thanks!


macros.run "Modifier Stack" "Convert_to_Poly"
modPanel.addModToSelection (Edit_Poly()) ui:on
subobjectLevel = 5
actionMan.executeAction 0 "40021"  -- Selection: Select All
$.EditablePoly.setMaterialIndex 1	

4 Replies
 em3

annnnd the fix. I should learn by now that I need to post every problem I have. It always seems that when I post it – the solution presents itself.

$.modifiers[#Edit_Poly].SetOperation #SetMaterial
$.modifiers[#Edit_Poly].materialIDToSet = 0
$.modifiers[#Edit_Poly].Commit ()
 JHN

You can also apply a material modifier and set it to 1 and collapse.


  (
 addModifier $ (Materialmodifier materialid:1)
    convertTo $ editable_Poly 
  )
  

-Johan

*edit: see pixel_monkeys comment, good catch!
*edit2: thanks martijn, maybe I should check first before posting

You may want to add a Poly Select or other modifier to remove any sub-object selections as the Material Modifier does support SO selections.

-Eric

When using the addModifier command, any subobject selections will be discarded anyway. modPanel.addModToSelection keeps it.

Martijn