ScriptSpot home

Forum topic · General Scripting

Create layers by materials - 3ds max

By mariano2cv · 2008-04-04

Description

Hello I would like to know how can I create a script that locates the scene objects depending of the object materials and names the layer depending of the material name... thanks for your help!

Comments (3)
bderrick

Great script, thanks for posting it.
Sometimes I have problems with it however. Max pops up an error about the addnode on the last line. I'm not experienced in scripting so any help would be great, thanks.

mainworks

-- put objects onto layers one layer for each material and name the layer by the material name
-- by Olaf Finkbeiner for www.mainworks.de

layers = #()
obj = #()
for o in geometry where o.material != undefined do (append obj o)
m = scenematerials
c = m.count
for i = 1 to c do (
layername = m[i].name
layer = layermanager.newLayerFromName layername
for o in obj where o.material.name == m[i].name do (layer.addnode o)
)

mainworks

Hi Mariano,
i just looked for something that does that and could not find it... So i will write it now...

kind regards

Olaf