Vsai
11-15-2005, 09:10 PM
Its looking like the only way to do this is through the edit poly modifier, but i'm having some problems, no errors are being thrown, but i can't appear to get it to work. code below:
-- 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
(
--selectfacesbyid
emod.selectByMaterialID = subindex
--detach & rename detached object for 'OrigionalName-material name'
newname = obj.name + "_" + obj.material[subindex].name
emod.detachtoobject newname
--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
-- 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
(
--selectfacesbyid
emod.selectByMaterialID = subindex
--detach & rename detached object for 'OrigionalName-material name'
newname = obj.name + "_" + obj.material[subindex].name
emod.detachtoobject newname
--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
