I have a script that merges all objects within a selection IF they share the same wirecolor.
The problem is that currently, this script changes the wirecolor of the merged objects. I need it to be kept the same as before they merged.
(
mtl = #() ; tmp = #() ; fin = #()
sel = selection as array
if sel.count == 0 then -- check selection
messageBox "Nothing selected!" title:"Attach by Wirecolor"
else
( -- filter selection
sel = for i in sel where canConvertTo i Editable_Mesh \
and i.wirecolor != undefined collect i
if sel.count <= 1 then -- 2nd check
messageBox "Procedure requered\nmore then 1 valid objects!" title:"Attach by Wirecolor"
else
(
for i in sel do
(
if findItem mtl i.wirecolor == 0 do
append mtl i.wirecolor
)
for m in mtl do
(
tmp = for i in sel where i.wirecolor == m collect i
append fin tmp
)
undo on
(
clearSelection()
for i in fin do
(
if i.count > 1 do
(
trg = snapshot i[1]
selectMore trg
delete i[1] -- del source obj
deleteItem i 1 -- del item array
for j in i do
meshop.attach trg j
)
)
)
)
)
)
Could anyone modify it to preserve the wire color? It would also be nice to have the result be editable poly rather than editable mesh, but it's not needed. I'd really appreciate any help. Thanks!
By Stenrik · 2020-04-12
miauu · 2020-04-12