Assign a temporary material to check UV´s?

Hi all!

Usually I have a lot of objects in my scene and therefore a lot of materials in the Mat editor. Is it possible to make a script that temporarily assigns a second material to a selection, lets say for example to assign a UV map for cheking the UV´s. And when finished the original materials are assigned back to the selected objects?

Take care all!

/Matt

Comments

Comment viewing options

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

mind pasting the error? :P

mind pasting the error? :P

Raphael Steves

Massemannen's picture

Strange, now it works and it

Strange, now it works and it looks great!!!
Don´t know what happened, sorry about that...

Massemannen's picture

Error

Hi!
Yes; I meant Happy New Year

Sorry to be a pain, but I get an error at line 36 (on assignCheckMat pressed do)

/M

Graph's picture

( rollout ro "" ( local

(
	rollout ro ""
	(
		local data = #()
 
		local texPath = ""
 
		button pckTex "Pick Texture" width:(ro.width-10) height:25 toolTip:"Pick your own checker Texture\n<Optional>"
 
		spinner tilesS "Tiles" range:[0.001,99999999,5] align:#left width:(ro.width-20)
 
		group "RealWorld Scale"
		(
			checkButton rwScale "Use" checked:false
			spinner realWorldHeight "W" range:[0.001,99999999,5] enabled:false align:#left width:((ro.width-25)/2) across:2
			spinner realWorldWidth "H" range:[0.001,99999999,5] enabled:false align:#right width:((ro.width-25)/2)
		)
 
		button assignCheckMat "Assign Checker" width:(ro.width-10) height:30
 
		button reAssignOldMats "ReAssign Old Mats" width:(ro.width-10) height:30
 
		on rwScale changed state do (realWorldHeight.enabled = realWorldWidth.enabled = state; tilesS.enabled = not state)
 
		on pckTex pressed do
		(
			pckTex.enabled = false
 
			local tPath = getOpenFileName caption:"Pick your custom Checker Texture" types:"Texture File bmp|*.bmp|Texture File jpg|*.jpg|Texture File gif|*.gif|Texture File png|*.png|Texture File tga|*.tga|Texture File tif|*.tif|Texture File dds|*.dds|Texture File psd|*.psd|Texture File hdr|*.hdr|Texture File cin|*.cin|Texture File cws|*.cws|Texture File exr|*.exr|Texture File fxr|*.fxr|Texture File pic|*.pic|Texture File ifl|*.ifl|Texture File jpe|*.jpe|Texture File jpeg|*.jpeg|Texture File rgb|*.rgb|Texture File rgba|*.rgba|Texture File sgi|*.sgi|Texture File int|*.int|Texture File inta|*.inta|Texture File bw|*.bw|Texture File rla|*.rla|Texture File rpf|*.rpf|Texture File vda|*.vda|Texture File icb|*.icb|Texture File vst|*.vst|Texture File yuv|*.yuv|" --"Data(*.dat)|*.dat|Excel(*.csv)|*.csv|All|*.*|"
 
			if tPath != undefined and doesFileExist tPath then texPath = tPath else texPath = ""
 
			pckTex.enabled = true
		)
 
		on assignCheckMat pressed do
		(
			local sel = selection as array
 
			if sel.count > 0 do
			(
				data = for o in sel collect #(o, o.material)
 
				local chkMap = if doesFileExist texPath then bitmaptex fileName:texPath else checker()
				chkMap.coords.V_Tiling = chkMap.coords.U_Tiling = tilesS.value
				chkMap.coords.realWorldScale = rwScale.checked
				chkMap.coords.realWorldHeight = realWorldHeight.value
				chkMap.coords.realWorldWidth = realWorldWidth.value
 
				sel.material = standardMaterial diffuseMap:chkMap showInViewport:true
			)
		)
 
		on reAssignOldMats pressed do
		(
			for d in data do d[1].material = d[2]
		)
	)
	createdialog ro 
)

happy new year i think you mean

Raphael Steves

Massemannen's picture

Tnx Raphael! I´m truly

Tnx Raphael!

I´m truly greateful for all your help... Is there a command for "Use Real-World scale" instead of the Tile function? Perhaps have it as a tick box.
I wish I had the knowledge to write maxscript´s

Merry Xmas

/Matt

Graph's picture

;)

local chkMap = bitmaptex fileName:@"C:\foo\bar\hum.bug"

Raphael Steves

Graph's picture

i take it you want the

i take it you want the checkMat to be a standardMat with a checkerMap displayed?

(
	rollout ro ""
	(
		local data = #()
 
		spinner tilesS "Tiles" range:[0.001,99999999,5]
		button assignCheckMat "Assign Checker" width:(ro.width-10) height:30
 
		button reAssignOldMats "ReAssign Old Mats" width:(ro.width-10) height:30
 
		on assignCheckMat pressed do
		(
			local sel = selection as array
 
			if sel.count > 0 do
			(
				data = for o in sel collect #(o, o.material)
 
				local chkMap = checker()
				chkMap.coords.V_Tiling = chkMap.coords.U_Tiling = tilesS.value
 
				sel.material = standardMaterial diffuseMap:chkMap showInViewport:true
			)
		)
 
		on reAssignOldMats pressed do
		(
			for d in data do d[1].material = d[2]
		)
	)
	createdialog ro 
)

Raphael Steves

Massemannen's picture

That is sooooo freakin´

That is sooooo freakin´ cool!!! Thank you very much!
What if I would like a bitmap instead of a checker map? I always use the same UV bitmap...

/Masse

Comment viewing options

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