I wrote a sample script that copies and pastes uv maps between 2 geometries that have the same geometry data. This is a workaround that works because you cannot literally copy and paste uvs. This preserves polygroups,material. polypaints, layers, morph target, etc. In short it only tranfers uv maps. You could try it. modify, include in your scripts. You could call the routine in your scripts if you want to use it but make sure to edit the NOte messages to your likings. I might post a short clip demonstrating this one.
This is the ZScript Text File
CopyPasteUV.txt (5.16 KB)
[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.
[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, 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.
[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]
[ISet, Edit:Tool:UndoCounter, 1]
[IPress, Edit:ToolDelUH]
[SubToolSelect, ([SubToolGetActiveIndex]-1)]
[ISet, Tool:Polygroups:PTolerance, .1]
[IPress, “Tool:Polygroups:From Polypaint”]
[IPress, Tool:UV Map:Uvp]
[IPress, “Tool:UV Map:Morph UV”]
// 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]
[IPress, “Tool:Import: Import”]
// 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]
[FileNameSetNext, #filePath]
[IPress, Tool:Export]
[IKeyPress, ‘2’,
[IPress, Tool:SubToolDelete]
]
[IPress, Tool:UV Map:Uvp]
[IPress, “Tool:UV Map:Morph UV”]
[FileNameSetNext, #filePath]
[IPress, “Tool:Import: Import”]
[IPress, “Tool:UV Map:Morph UV”]
[ISet, Tool:Geometry:SDiv, #currSubD]
[ISet, “Preferences:Interface:Morph UV Timer”, #morphTimer] //Restore this setting.
[VarSet, [Var, successOuput],1 ] // Return value
,//INVALID
[IKeyPress, ‘2’,
[IPress, Tool:SubToolDelete]
]
[SubToolSelect, #currSubTool]
[VarSet, [Var, successOuput],0 ]// Return value
]
, // SOURCE MESH HAS NO UV MAP
[IKeyPress, ‘2’,
[IPress, Tool:SubToolDelete]
]
[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.”]
,]
]
CopyPasteUV.txt (5.16 KB)