Attach by Same Material

2 votes
Version: 
v1.0
Date Updated: 
10/30/2016

Attached all geometry with the same material to the currently selected object. This collapses to editable poly first, so make sure you're cool with that before you click. :)

Created for merging objects in heavy architecture scenes recieved in Max format with large numbers of individual objects.

AttachmentSize
smallpoly_AttachSameMat.ms961 bytes

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
obaida's picture

superclassof Targetobject is

superclassof Targetobject is GeometryClass and throw error when getting its material

Nik's picture

Так будет лучше на все выделенные объекты

(
if selection.count >= 1 do for i in selection do
if (superclassof i == GeometryClass) do
	(
	if (classof i != Editable_Poly) do convertTopoly i
	mainobject=i
	mat = i.material
	for o in objects do	if o.material == mat then mainobject.EditablePoly.attach o mainobject
	)
)
Bormax's picture

Thanks

Thank you for original script!
And thank you Qwertzus for the great update - very useful!

Qwertzus's picture

attach with multiple materials

Hi awesome,
a bit late but here you go :D

mtl = #() ; tmp = #() ; final = #()
    sel = selection as array
 
    if sel.count != 0 then
    (
        for i in sel do
        (
            convertTo i Editable_Poly
            i.name = i.material.name
            --append all materials of selection to the mtl array:
            if findItem mtl i.material == 0 do
            append mtl i.material
        )
        for m in mtl do
        (
            tmp = for i in sel where i.material == m collect i -- tmp stores all objects with the same material
            append final tmp -- append tmp array to final array
        )
        for i in final do
        (
            if i.count >= 1 do
            (
                mainobject = i[1] --first index will be the mainobject to attach to
                for j in i do
                mainobject.EditablePoly.attach j mainobject
            )
        )
    )
Smallpoly's picture

Thanks for the feedback. The

Thanks for the feedback. The next time I do an update to this script that's one of the things I'd like to add in.

sirmontal's picture

awesome

hey mate thanks for this - handy!
Would be awesome if you could select ALL geometry and it attaches them by maerial. The way it is now, you have to select 1 piece of geometry at a time

great work either way

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.