View Full Version : unwrap uvw: spacing not working in flatten mapping function

03 March 2009, 11:23 AM
I need to do an automatic flatten mapping on a bunch of objects with spacing=0.01 and both the flattenMap and flattenMapNoParams functions seem to be using the default spacing of 0.02.

This code will create a box and try to auto flatten map it: (
size = 3
o = Box isSelected:true
addModifier o ( Unwrap_UVW() )
m = o.modifiers[1]
-- first method:
m.setFlattenSpacing 0.01 -- sets the default spacing to 0.01
m.flattenMapNoParams() -- supposed to do flatten mapping using the current default parameters
-- second method
--m.flattenMap 45.0 #() 0.01 true 0 true true -- same as above only you pass parameters rather than using the current defaults
)Is this a bug or am I doing something wrong?

03 March 2009, 03:58 AM
using a line like this...

m.flattenMap 45.0 #([1,0,0], [-1,0,0], [0,1,0], [0,-1,0], [0,0,1], [0,0,-1]) 0.01 true 0 true true

worked for me recently. the gotcha is the faces need to be selected for it to work. here's an example on editable poly object...

myUV = $.unwrap_UVW
z = $.getNumFaces()
myUV.selectFaces #{1..z}

myUV.flattenMap 45.0 #([1,0,0], [-1,0,0], [0,1,0], [0,-1,0], [0,0,1], [0,0,-1]) 0.01 true 0 true true

03 March 2009, 09:46 AM
the function does work, it just seems to leave the spacing at 0.02 even when i specify 0.01
I played around some more and found that 0.005 or 0.015 was equivalent to 0.01 for some weird reason. Good enough for now. Thanks anyway!

03 March 2009, 03:35 PM
you're right. no need to select anything so that makes things MUCH faster. one thing to note, tho - when i try your function in max2009 i can specify the setFlattenSpacing & the results are as i expect. for example i changed the spacing value to .0001 to see how fine i could get it & it works! just select the lower-leftest most vert in the unwrap & check it's position (the spinners don't have enough digits for accuracy)...

here's the hack code to check...

vert = $.UnwrapUVW.getselectedVertices ()
vert = vert as array
$.UnwrapUVW.getVertexPosition 1 vert[1]

what version of max are you working with?

03 March 2009, 03:40 PM
You probably need to change your decimal display settings in Max to a value greater than the default of 3, I usually set it at 5 or 7. Customize > Preferences > Spinners > Precision.


03 March 2009, 01:20 AM
ok i figured it out. The 'problem' seems to be that the value you need to pass to the flattenMap function for spacing needs to be divided by 2 to get the same result as you do with the UI dialog. Also you need to have the object selected, the command panel should be in modifier mode and subobjectlevel should be set to 3 (face). the below code gets the same result as the interface.(
size = 3
o = Box isSelected:true
addModifier o ( Unwrap_UVW() )
max modify mode
subobjectlevel = 3
m = o.modifiers[1]
spacing = 0.01
m.flattenMap 45.0 #([1,0,0], [-1,0,0], [0,1,0], [0,-1,0], [0,0,1], [0,0,-1]) (spacing/2) true 0 true true

CGTalk Moderation
03 March 2009, 01:20 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.