problem attaching mesh
hi guys, i'm really new on 3DSMAX and scripting, so excuse my horrible mistakes, well my problem is attaching meshes in 3DS Max, what i need is a script that attach all the meshes in one, no matter if they have diffent materials, i have this script:
mtl = #() ; tmp = #() ; fin = #()
sel = selection as array
if sel.count == 0 then -- check selection
messageBox "Nothing selected!" title:"Attach Mesh by Material"
( -- filter selection
sel = for i in sel where canConvertTo i Editable_Mesh \
and i.material != undefined collect i
if sel.count <= 1 then -- 2nd check
messageBox "Procedure requered\nmore then 1 valid objects\nwith assigned materials!" title:"Attach Mesh by Material"
for i in sel do
if findItem mtl i.material == 0 do
append mtl i.material
for m in mtl do
tmp = for i in sel collect i
append fin tmp
for i in fin do
if i.count > 1 do
trg = snapshot i
delete i -- del source obj
deleteItem i 1 -- del item array
for j in i do
meshop.attach trg j attachMat:#IDToMat condenseMat:true
but when i run it, it displays this error: Runtime error: Attempt to access deleted scene object on this lines of the code: trg = snapshot i
i don't know what to do!!! can anyone help me!!!
thank you so much!