Material name select

Hi How can i select all the objects in the scene by its material name?
lets say material name is "Grass1" i want to have a button you press it and it only finds material name called "grass1" thanks

Comments

Comment viewing options

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

try this

-- function
fn findObjsByMtlName name = (
	local theObjs = #()
	theMtl = (for m in sceneMaterials where \
		m.name == name collect m)[1]
	if theMtl != undefined do (
		theObjs = for n in (refs.dependents theMtl) where \
		superClassOf n == GeometryClass collect n
	)
	theObjs
)
 
-- usage
select (findObjsByMtlName "Grass1")

* note - this function is case sensitive, ie "Grass1" is not equal to "grass1"

my recent MAXScripts RSS (archive here)

Mrjacks2o's picture

Thanks allot! Works

Thanks allot! Works perfectly...
like i said before the forum needs you :)

Comment viewing options

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