Notifications
Clear all

[Closed] UVW Channel moving

This is a snippet from a tool I’m writing to streamline some processes for our artists. We have models are unwrapped on channel 1, then unwrapped on channel 3 for baking. Once we have baked a texture we drop channel 3 onto channel 1 and apply the baked texture.

Now I’ve basically tried to recreate the process in maxscript and hit a problem. When the object already has UVW modiifier in the stack on channel 3, it works fine. However if the stack is collapsed, I would expect my code to add a unwrap modifier go to channel 3 and reset, then move that to channel 1. What it actually does is change the modifier to channel 1 without actually moving the UVWs.

I’m using max 2012


-- check if UV Modifier exists
if (ClassOf $.modifiers[1]) == unwrap_uvw then
	(
		print ("unwrap modifier exists")
		-- uvw modifier exists, assume it's on channel 3, so set it to channel 1
		$.unwrap_uvw.unwrap.setMapChannel 0
	)
	--else add UV Modifier
	--select channel 3, then reset UV then channel 1
else
	(
		print ("no unwrap modifier exists")
		-- add uvw modifier
		modPanel.addModToSelection (Unwrap_UVW ()) ui:on
		-- set uvw channel to 3
		$.modifiers[#unwrap_uvw].unwrap.setMapChannel 3
		-- reset uvws
		$.modifiers[#unwrap_uvw].unwrap.reset ()
		-- set uvw channel to 1
		$.modifiers[#unwrap_uvw].unwrap.setMapChannel 0
	)