Diffuse Alpha Channel to Opacity Channel

I'm having to import over a thousand 3ds objects into max, each objects material (TGA) has an alpha channel. All I need to do is the Copy Diffuse slot to Opacity slot and set the mono channel output to alpha.
I've been trawling scriptspot for ages, there are lots of Material scripts, but I can't find one that will do this simple task.

I get this from listener.....

meditMaterials[1].opacityMap = Bitmaptexture fileName:"C:\Program Files\Infogrames\Grand Prix 4\Tracks\my_track\Import Full Track To Max Test Track\melborne2001\maps\melborne2001\page_335.tga"

meditMaterials[1][#Maps][#Opacity__Map__856__page_335_tga].monoOutput = 1

But I can't figure out how to just use it on the selected slot, or preferably all slots in the material editor, basically I need that little bit of script to work without looking for the specific tga image name.

btw I'm a Maxscript Luddite...go easy on me ;) [email protected] hoping script already exists

tia

Comments

Comment viewing options

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

replace mat with material

replace mat with material

Raphael Steves

asymptote's picture

Hmmm... I've come back to

Hmmm... I've come back to using this script in Max 2011 and now I get a

-- Unknown property: "mat" in undefined when I run it, I can't figure it out....can anyone help?

thx

real08121985's picture

:D sry my fail, dont read

:D sry my fail, dont read your post correctly

asymptote's picture

That didn't, but it was

That didn't, but it was easy for me to change the last line to this...and it works perfectly :)

Obj.mat.opacityMap.monoOutput = 1

Many thanks, it's a big help...and sort of my first ever script ;)

real08121985's picture

Don't know if this solves

Don't know if this solves your problem. Copies the diffusemap to opacity channel and set the output-invert to true

(
	for Obj in objects do (
		Obj.mat.opacityMap = copy Obj.mat.diffuseMap
		Obj.mat.opacityMap.output.invert = true
	)
)

Comment viewing options

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