[RoutineDef, CopyUV, // ROUTINE FOR COPYING UVS [IFreeze, [Note, "Copying UVs. Please wait..."] [VarSet, isSuccessful, 0] [VarSet, hasUV, 0] [VarSet, morphUVStat, [IGetStatus, "Tool:UV Map:Morph UV"]] [If, #morphUVStat , [VarSet, hasUV, 1] ,] [If, #hasUV, // has UV [IPress, Tool:Visibility:ShowPt] // Make sure to show all polygons before copying in the memory [VarSet,sdivCurrent, [IGet,"Tool:Geometry:SDiv"]] [ISet, "Tool:Geometry:SDiv", 1] // Copy from the lowest level [IPress, Tool:Geometry:Copy] [ISet, "Tool:Geometry:SDiv", #sdivCurrent] [VarSet, isSuccessful, 1] , // has no UV [VarSet, isSuccessful, 0] ] [VarSet, [Var,successOuput], #isSuccessful] // Return value ] , successOuput] [RoutineDef, PasteUV, // ROUTINE FOR PASTING UVS [IFreeze, [Note, "Pasting UVs. Please wait..."] [VarSet, currSubTool,[SubtoolGetActiveIndex]] [IPress, Tool:Visibility:ShowPt] // Shows any polygons first to make it properly work. [VarSet, currSubD,[IGet, Tool:Geometry:SDiv]] // Store this so you can restore the current subdivision level later. [VarSet, undo1, [IGet, Edit:Tool:UndoCounter]] [ISet, Tool:Geometry:SDiv, 1]// Set the subdiv to the lowest level [VarSet, polyCount1, 0] [Mesh3DGet,0,,,polyCount1]//Get the polygon count of level 1 [IPress, Tool:SubTool:Duplicate] [IPress, "Tool:Geometry:Paste Replace"] [VarSet, UVMorphStat, [IGetSTatus, "Tool:UV Map:Morph UV"]] [VarSet , hasUV,#UVMorphStat]// Double checks if the source mesh has uv map [If, #hasUV,// SOURCE MESH HAS UV MAP //Validates if the source mesh and the target mesh has the same level 1 polygon data [ISet, Tool:Geometry:SDiv, 1]// Set the subdiv to the lowest level [VarSet, polyCount2, 0] [Mesh3DGet,0,,,polyCount2]//Get the polygon count of level 1 [VarSet, isLevel1TheSame, 0] [If, #polyCount1 == #polyCount2, [VarSet, isLevel1TheSame, 1] // It means it is valid and will proceed in transferring uvs. , [VarSet, isLevel1TheSame, 0] // It means it is invalid and will not transfer any uv data. ] [If, #isLevel1TheSame,//VALID [VarSet, soloFl, [IGetFlags, Transform:Solo]] [IPress, Transform:Solo] [VarSet, morphTimer,[IGet, "Preferences:Interface:Morph UV Timer"]]//Save this settings so it can be restore later [ISet, "Preferences:Interface:Morph UV Timer", 0] // Set this to 0 so uv morphing is not animating. [IUnPress, "Tool:UV Map:Morph UV"] [IPress, "Tool:UV Map:Morph UV"] // These make sure that these settings are always in their default values to make it work properly. [IPress, Tool:Export:Txr] [IUnPress, Tool:Export:Flp] [IPress, Tool:Export:Mrg] [IPress, Tool:Export:Grp] [IPress, Tool:Export:Qud] [ISet, Tool:Export:Scale, 1] [ISet, "Tool:Export:X Offset", 0] [ISet, "Tool:Export:Y Offset", 0] [ISet, "Tool:Export:Z Offset", 0] [VarSet, filePath,[FileNameResolvePath, "UVMesh.obj"]] [FileNameSetNext, #filePath] [IPress, Tool:Export] [IKeyPress, '2', [IPress, Tool:SubTool:Delete] ] [SubToolSelect, #currSubTool] [VarSet, undo2, [IGet, Edit:Tool:UndoCounter]] [If, #undo2 > #undo1, [MergeUndo] ,] [IUnPress, "Tool:UV Map:Morph UV"]// This unpressing makes it sure that it is off before the uv mapping [MergeUndo] [IPress, Tool:UV Map:GUVTiles]// Creates a map using GUVTiling [MergeUndo] [IPress, "Tool:UV Map:Morph UV"] [MergeUndo] [IPress, "Tool:Polypaint:Polypaint From Polygroups"] [MergeUndo] [IPress, Tool:Masking:Inverse] [MergeUndo] [IPress, "Tool:Polypaint:Polypaint From Polygroups"] [MergeUndo] [IPress, Tool:Masking:Inverse] // These make sure that these settings are always in their default values to make it work properly. [IunPress, Tool:Import:Mrg] [IunPress, Tool:Import:Add] [ISet, Tool:Import:Tri2Quad, 0] [ISet, Tool:Import:Weld, 0] [FileNameSetNext, #filePath] [MergeUndo] [IPress, "Tool:Import: Import"] [ISet, "Tool:Polygroups:PTolerance", .5] [MergeUndo] [IPress, "Tool:Polygroups:From Polypaint"] [MergeUndo] [IUnPress, "Tool:UV Map:Morph UV"] [VArSet, subDivLvl, [IGet, Tool:Geometry:SDiv]] [If, #subDivLvl == #currSubD , , [MergeUndo] ] [ISet, Tool:Geometry:SDiv, #currSubD] [ISet, "Preferences:Interface:Morph UV Timer", #morphTimer] //Restore this setting. [If, (#soloFl == 8) || (#soloFl == 10) , [IUnPress, Transform:Solo] ,] [VarSet, [Var, successOuput],1 ] // Return value ,//INVALID [IKeyPress, '2', [IPress, Tool:SubTool:Delete] ] [SubToolSelect, #currSubTool] [VarSet, [Var, successOuput],0 ]// Return value ] , // SOURCE MESH HAS NO UV MAP [IKeyPress, '2', [IPress, Tool:SubTool:Delete] ] [SubToolSelect, #currSubTool] [VarSet, [Var, successOuput],0 ]// Return value ] ] , successOuput] [IButton, CopyUVS, "", [VarSet, success, 0] [IKeyPress, '1', [RoutineCall, CopyUV, success] ] [If, #success == 0 , [Note, "Mesh has no UV Map. Copy failed."] ,] ] [IButton, PasteUVS, "", [VarSet, success, 0] [IKeyPress, '1', [RoutineCall, PasteUV, success] ] [If, #success, [Note, "UV pasting successful."] ,] ]