ScriptSpot

Script

Attach by Same Material

By Smallpoly · 2016-10-31

Version
v1.0
Date updated
2016-10-30
Votes
2
Description

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.

Attachments

Tags: Material, geometry, attach, smallpoly

Comments (6)

Thanks

Bormax · 2021-03-03

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

awesome

sirmontal · 2016-11-10

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

Smallpoly · 2017-05-10

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.

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

Nik · 2021-12-29


(
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
	)
)

obaida · 2022-01-01

superclassof Targetobject is GeometryClass and throw error when getting its material

attach with multiple materials

Qwertzus · 2020-01-10

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
            )
        )
    )