transfering uvw data via maxscript

transfering uvw data via maxscript

Anonymous
Not applicable
3,253 Views
22 Replies
Message 1 of 23

transfering uvw data via maxscript

Anonymous
Not applicable
i am completely new to maxscript, so maybe this is a dumb question:
i am trying to use maxscript to transfer uvw coordinates from one object to another.
my test file contains a poli called 01 and another one called 01a (the final file will have a series of such groups (02/02a, 03/03a,...)).
01 has an unwrapUVW modifier containing the correct cordinates which should be transferred to 01a.
i tried with recording a drag and drop action of the modifier, but this did not work.
i also tried to safe and load the uvs with the following script:

macroScript Macro27
category:"DragAndDrop"
toolTip:""
(
actionMan.executeAction 0 "40021" -- Selection: Select All
macros.run "Modifier Stack" "Convert_to_Poly"
$.material = meditMaterials
clearSelection()
select $a1
subobjectLevel = 4
$.EditablePoly.attach $1 $
subobjectLevel = 0
modPanel.addModToSelection (Uvwmap ()) ui:on
$.modifiers.length = 40.71
$.modifiers.width = 210.34
modPanel.setCurrentObject $.baseObject
subobjectLevel = 4
$.EditablePoly.SetSelection #Face #{1}
actionMan.executeAction 0 "40020" -- Edit: Delete Objects
$.EditablePoly.delete #Face
subobjectLevel = 0
modPanel.setCurrentObject $.modifiers
modPanel.addModToSelection (Unwrap_UVW ()) ui:on
$.modifiers.unwrap.save ()
select $t1
modPanel.addModToSelection (Unwrap_UVW ()) ui:on
$.modifiers.unwrap.load ()
)


basically it works, but it asks me where to safe the uvw-file and then again asks which uvw file to load, which is not so convinient. can i specify a path in the script, which says where to save and load the uv date?
of course i would prefer transferring the data without saving in between.
any help would be appreciated
0 Likes
3,254 Views
22 Replies
Replies (22)
Message 21 of 23

Anonymous
Not applicable


Thanks for your advice, ChannelInfo or Projection help in any cases… However, manual copy/paste unwrap_UVW also works fine, just doing via MaxScript is wrong but… I have a good news… I found a very elegant solution using “swap” function (an awesome miscellaneous funcion that save my *** :) many times in a lot of situations). If anybody need my way, I’ll share “how to”. Thanks again for the reply.
Author: Anubis


seems i am the only non-professionalist in this thread.
i like elegant solutions and would like to read it.
could you please share?
0 Likes
Message 22 of 23

Anonymous
Not applicable
If the vertex count is the same then you may want to look at ChannelInfo or using the Projection modifier to transfer the mapping data.

-Eric

using channelinfo works like a charm.
thanks a lot
0 Likes
Message 23 of 23

Anonymous
Not applicable
Ok, their is what I do. "srcObj" is the object from that I copy unwrap_UVW and "trgObj" is the object that I paste to, end the code is:
tmpObj = copy srcObj -- create a temp copy from source
tmpObj.transform = trgObj.transform -- align to target object
trgMods = trgObj.modifiers -- get modifiers to can transfer them too leter on
-- the "core" trick is here:
swap tmpObj.baseObject trgObj.baseObject -- swap base objects
swap tmpObj.name trgObj.name -- swap their names as well
-- now transfer modifiers:
for m = trgMods.count to 1 by -1 do (addModifier tmpObj trgMods)
delete trgObj -- delete tmp copy

This way not need to add unwrap_UVW modifier on target object, at the end it will own original modifier from temp copy ;)
0 Likes