macroScript gp_collectByWirecolor category:"gp_tools" tooltip:"collectByWireColor" ( local doCollect = false local gp_colorArr =#() for i = 1 to selection.count do( if classof selection[i] != Editable_poly then( messagebox "one of the objects is not a polyObject" exit ) else( if i == selection.count then( doCollect = true global gp_selectedArr = selection as array ) ) ) local gp_sameColorArr =#() clearSelection() fn gp_collectByWirecolor = ( if doCollect == true then( if gp_selectedArr.count >1 then( for i in gp_selectedArr do( if findItem gp_colorArr i.wireColor == 0 then append gp_colorArr i.wireColor ) for c = gp_colorArr.count to 1 by -1 do( myColor = gp_colorArr[c] for s = gp_selectedArr.count to 1 by -1 do( myObj = gp_selectedArr[s] if gp_selectedArr[s].wireColor.red == myColor.red then( if gp_selectedArr[s].wireColor.green == myColor.green then( if gp_selectedArr[s].wireColor.blue == myColor.blue then( theObj = myObj deleteItem gp_selectedArr s append gp_sameColorArr myObj ) ) ) ) myObj = undefined deleteItem gp_colorArr c --print gp_sameColorArr for a = gp_sameColorArr.count to 2 by -1 do( tempObj = gp_sameColorArr[a] --print ("tempObj " + (tempObj.name as string)) deleteItem gp_sameColorArr a polyop.attach gp_sameColorArr[1] tempObj centerPivot gp_sameColorArr[1] ) tempObj = undefined gp_sameColorArr =#() ) gp_colorArr =#() gp_selectedArr =#() ) ) ) --execute! gp_collectByWireColor() )