Pages

Monday, August 3, 2009

Put Selected to MEditor Slots

2 days ago i just wrote a script to shift materials between Scene, Material Editor slots and current Library. But i think so i miss something :) so i post today here 2 maxscripts that put materials from selected scene objects to Material Editor. The difference between this 2 versions is only in slots ordering. In first version they will be appended started from 1st MEditor Slot and in second version they will be appended starting from current active MEditor Slot, that i think is more useful.

-- add Materials from Selected objects to MEditor slots
---------------------------------------------------------------
-- [V.1] - starting from 1st MEditor Slot

(
local sel = selection as array
if sel.count == 0 then
messageBox "Nothing selected!" title:"Selection"
else
(
mtl = #()
for i in sel where i.material != undefined do
appendIfUnique mtl i.material
if mtl.count > 0 do -- if there materials
(
if mtl.count > 24 do -- if they are > 24
mtl.count = 24 -- keep 24 of them
for m in 1 to mtl.count do
meditMaterials[m] = mtl[m]
)
)
)
-- [V.2] - starting from current Active MEditor Slot
(
local sel = selection as array
if sel.count == 0 then
messageBox "Nothing selected!" title:"Selection"
else
(
mtl = #()
for i in sel where i.material != undefined do
appendIfUnique mtl i.material
ams = activeMeditSlot
if mtl.count > 0 do
(
freeSlots = 25 - ams
if mtl.count > freeSlots do
mtl.count = freeSlots
for m in 0 to mtl.count-1 do
meditMaterials[ams+m] = mtl[1+m]
)
)
) -- end

No comments:

Post a Comment

Thanks for your comment