-- Detach by material script
-- Mainly to help keep us sane from Sketchup imports.
sel = selection as array
--for each selected object
emod = Edit_Poly()
for obj in sel do
--if it has a multi sub attached
if (obj.material != undefined) do
if (obj.material.numsubs != undefined) do
--add edit poly modifier
-- Can be REALLY SLOW.
addmodifier obj (emod)
--for each sub material of the edit poly modifier
for subindex in 1 to obj.material.numsubs do
emod.selectByMaterialID = subindex
--detach & rename detached object for 'OrigionalName-material name'
newname = obj.name + "_" + obj.material[subindex].name
--Todo: attach material
--Todo: copy over any uvw's or vraydisplacementmods
If anyone has any ideas, i'd be much appreciative.. I've also tried sticking into SubObjectLevel = 4 before getting to the submaterial loop, but that appears to break out of the script altogether