Material ID Flatten Unwrap

I'm a 3d artist and I don't know anything about scripting so would really appreciate help with this!

Basically I have lots of buildings to unwrap. So far the buildings have separate material IDs applied to them For each type of material (about 10 ids in total) such as concrete and metal etc.

Since I am using tillable textures I just need a quick flatten unwrap pack for each channel ID.

I think the scipt would do something like this:

Select Object

Select Material ID (1)

Unwrap Modifier

(in UV editor)

Flatten Mapping

Selected Inverted faces

Flip faces

Pack UVs

Collapse UV Modifier

Repeat.

Many thanks for any help with this

Chris

Comments

Comment viewing options

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

Help! Doesn't work for me

I run your script and I got this message:

-- Unknown property: "Unwrap_UVW" in undefined
-- Error occurred during fileIn in
>> MAXScript FileIn Exception: -- No "map" function for undefined <<
-- Syntax error: at ), expected
-- In line: )
-- Error occurred during fileIn in
>> MAXScript FileIn Exception: -- Type error: Call needs function or class, got: undefined <<

Could you help me? This would be very useful for me!

Thanks!

Sanislov's picture

Hello. Maybe something like

Hello. Maybe something like this? Select all your objects, and run it.

setCommandPanelTaskMode #modify
 
Objs = #()
Objs = for a in selection collect a
 
if Objs[1] == undefined then (messagebox "Need to select object(s)!")
else(
	for o in Objs do
		(
		select o
		print o.name
		allIDs = #()
 
		for i = 1 to o.faces.count do
			(
			index = polyop.getFaceMatID o i
			if (allIDs[index] == undefined) do ( allIDs[index] = #())
			Append allIDs[polyop.getFaceMatID o i] i 
			)
 
		addmodifier o (unwrap_uvw())	
		for j = 1 to allIDs.count do
			(
			o.unwrap_uvw.selectfaces (allIDs[j] as bitArray)
			o.unwrap_uvw.flattenMap 45 #() 0 true 0 true true
			)
 
		collapseStack o
		)
)

Comment viewing options

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