PDA

View Full Version : flattenMap call from inside a function does not work


arnecls
02-15-2006, 03:51 PM
Hi
I'm new to maxscript (started yesterday) and have a problem calling flattenMap from inside a function:


function AO_UVWUnwrap _Object =
(
Unwrapper = UVWunwrap()
Unwrapper.setApplyToWholeObject true
addModifier _Object (Unwrapper)
Unwrapper.setMapChannel 2
Unwrapper.flattenMap 45.0 #() 0.001 true 0 true true
)


The ,appingchannel is properly changed, but flattening did not work at all
The funny thing about this is, that if I return the Unwrapper object and call the line


Unwrapper.flattenMap 45.0 #() 0.001 true 0 true true


OUTSIDE of the function it works perfectly.
I'm totally clueless why this happens ...

hblan
02-17-2006, 05:51 AM
-- i think the flatten is different to each object.
-- so the flatten command should after some objects.
-- and after flatten, the flattenMap is different too .

function AO_UVWUnwrap _Object =
(
Unwrapper = unwrap_uvw()
Unwrapper.setApplyToWholeObject true
addModifier _Object (Unwrapper)
Unwrapper.setMapChannel 2
--Unwrapper.flattenMap 45.0 #() 0.001 true 0 true true
)
theBox = box()
thesphere=sphere()
-------------------------
AO_UVWUnwrap theBox
theBox.modifiers[1].flattenMap 45.0 #() 0.001 true 0 true true
--------------------------
AO_UVWUnwrap thesphere
theSphere.modifiers[1].flattenMap 45.0 #() 0.03 on 0 on on

Bobo
02-17-2006, 06:04 AM
Hi
I'm new to maxscript (started yesterday) and have a problem calling flattenMap from inside a function:


function AO_UVWUnwrap _Object =
(
Unwrapper = UVWunwrap()
Unwrapper.setApplyToWholeObject true
addModifier _Object (Unwrapper)
Unwrapper.setMapChannel 2
Unwrapper.flattenMap 45.0 #() 0.001 true 0 true true
)




I'm totally clueless why this happens ...


Second day, and you have already hit a strange behaviour of the modifier stack! :)

This is really a very special case - what happens is that the modifier is added to the modifier stack, but the stack has not been properly updated internally when you call the flattenMap() function.

What you have to do just before calling the flattenMap() is to force an update of the stack. There are multiple ways to do this, including

classof _Object --probably the fastest way, although it looks like a hack

max modify mode --relatively fast, but updating the UI can still be slower than classof()

max select none --relatively slow, as it has to change the selection and redraw viewports
select _Object




function AO_UVWUnwrap _Object =
(
Unwrapper = UVWunwrap()
Unwrapper.setApplyToWholeObject true
addModifier _Object (Unwrapper)
Unwrapper.setMapChannel 2
classof _Object --asks for the class on top of the stack, thus forces an internal update
Unwrapper.flattenMap 45.0 #() 0.001 true 0 true true
)

arnecls
02-17-2006, 10:04 AM
Thanks a lot - that classof hack helped

48design
07-06-2006, 12:10 PM
hehe, exactly what I needed.

thanks to bobo and his experience! :thumbsup:

CGTalk Moderation
07-06-2006, 12:10 PM
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.