Mark Roberts
Mark Roberts

Reputation: 11

Maxscript trying to change material id of each object

I am using 3D Max Design which is odd with material ids. I am trying to revert all objects with name starting with Prism back to an id number of 10. I thought this would have been a bit straight forward however I am really new at Maxscript. My current code is such.

    myObjects = $'Prim-5m*' as array

     for i = 11 to myObjects.count do
       (
myobjects[i].modifiers[#VspMatMod].materialID=10
        )

I am not sure if I have to pass? I really don't understand how this works. The VsmMatMod is the modifier for the material channel of this object. If I was to convert the box to add a modifier of material would this work better? Please help Thanks

Upvotes: 0

Views: 1599

Answers (2)

barigazy
barigazy

Reputation: 46

Or you can simply use

for node in $Prism* where (modi = node.modifiers[#VspMatMod]) != undefined do  modi.materialID = 10

Upvotes: 0

Mark Roberts
Mark Roberts

Reputation: 11

sorted. I found another one liner for something else and modified it My resultant is;

        MyObjects = $'Pri*' as array

    for obj in myObjects do obj.modifiers[#VspMatMod].materialID = 10

Upvotes: 1

Related Questions