Automated Material Script

If anyone out there feels ambitious, could you write up this material automated script.

It simply takes the selected objects Material and prints it into the Maxscript Listner allowing users to copy the code from there and paste it into scripts for further use.

What's being printed in the Maxscript Listner is the code which creates the material on the currently selected object.

Thoughts? I'd like to know if anyone is interested?

Comments

Comment viewing options

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

the function itself doesnt

the function itself doesnt create anything except a stringstream/characterstream wich is returned as a plain old string

so if you feed an arch design mat in youll get that out

Raphael Steves

Graph's picture

was bored after all

(
 
	fn mat2mxs mat =	-- turns a supplied material into a mxs string you can execute to create it /doesnt include maps or arrays atm
	(
		local res
 
		if superCLassOf mat == material do
		(
			res = "" as stringStream
			format "%" (classOf mat) to:res
 
			local propNames = getPropNames mat 
 
			for propN in propNames do
			(
				local propV = getproperty mat propN
 
				if propV != undefined do
				(
					with printAllElements true
					(
						--format "%\t-\t%\t-\t%\n" propN (classOf propV) propV
						case classOf propV of
						(
							string : format " %:\\\"%\\\"" (propN as string) (propV) to:res
 
							color : format " %:%" (propN as string) ([propV.r,propV.g,propV.b,propV.a]) to:res
 
							default : if classOf propV != ArrayParameter do format " %:%" (propN as string) (propV) to:res
						)
					)
				)
			)
		)
		return (res as string)
	)--END mat2mxs FN
 
	local a = mat2mxs meditMaterials[2]
	print a
 
	/*a litle example how you can use the created string*/
-- 	local a = "Standardmaterial shaderType:1 wire:false twoSided:false faceMap:false faceted:false shaderByName:\"Blinn\" opacityType:0 opacity:100.0 FilterColor:[127.5,127.5,127.5,255] opacityFallOffType:0 opacityFallOff:0.0 ior:1.5 wireSize:1.0 wireUnits:0 applyReflectionDimming:false dimLevel:0.0 reflectionLevel:3.0 sampler:0 samplerQuality:0.5 samplerEnable:true samplerAdaptThreshold:0.1 samplerAdaptOn:true subSampleTextureOn:true samplerAdvancedOptions:true samplerByName:\"Adaptive Halton\" UserParam0:0.0 UserParam1:0.0 samplerUseGlobal:true adTextureLock:true bounce:1.0 staticFriction:0.0 slidingFriction:0.0 noExposureControl:false exposureControlInvertSelfIllum:false exposureControlInvertReflection:false exposureControlInvertRefraction:false ambient:[149.94,149.94,149.94,255] Diffuse:[149.94,149.94,149.94,255] Specular:[229.5,229.5,229.5,255] adTextureLock:true adLock:true dsLock:false useSelfIllumColor:false selfIllumAmount:0.0 selfIllumColor:[0,0,0,255] specularLevel:0.0 glossiness:10.0 Soften:0.1 Ambient_Color:[149.94,149.94,149.94,255] Diffuse_Color:[149.94,149.94,149.94,255] Specular_Color:[229.5,229.5,229.5,255] Self_Illumination:0.0 Self_Illum_Color:[0,0,0,255] Specular_Level:0.0"
-- 	if a != undefined do meditMaterials[13] = execute a
 
)

if anyOne cares you can also format it out to a verbatim string or use directly (dunno why one would do the latter) but then you gotta lose the extra formating for string classes
to lazy to build in handling for arrays but if one needs it its simple to implement
after adding array handling textureMaps will be quite simple too

have phun

Raphael Steves

JokerMartini's picture

Looks good.

Works pretty well. It seems though everytime I run the script it create an Arch Design MXS.

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

fajar's picture

you can try this script

you can try this script although it doesnt print mat prop in listener

Anubis's picture

Hi John, Im not understand...

Hi John,
Im not understand... did you looking for script that convert the material to mxs-code? And then execute this code to recreate the same material with all its settings?

my recent MAXScripts RSS (archive here)

JokerMartini's picture

Correct,

That is exactly what I want Anubis. A script that coverts a material to mxs code. Then recreates the same material when executed.

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

Anubis's picture

Check BFF

Check BFF - Bobo's File Format (2006) by Borislav Petrov:
http://www.scriptspot.com/3ds-max/scripts/bff-bobos-file-format

First update (2007) by Raúl Ortega Palacios:
http://www.scriptspot.com/3ds-max/scripts/bff-2007

This must by 2nd update (2008) by lostinspace:
http://www.scriptspot.com/forums/3ds-max/general-scripting/bbf-script
(but I dont see download link here)

my recent MAXScripts RSS (archive here)

Comment viewing options

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