Script impr. for Assigning UV Sets
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi there,
I am looking for improvements of the script I've assembled, in a way that would allow me to apply it on multiple selected objects without side effects.
Result I am after is having two uv channels containing the same layout and named regardless of initial condition this way:
UVMap
UVLightmap
Script thus far has 3 parts:
//Rename UV Set 1 to 'UVMap'
print("Renamed UV Set 1 to 'UVMap'");
string $eachElement;
string $sel[] =`ls -sl`;
for ($eachElement in $sel)
polyUVSet -rename -currentUVSet -newUVSet ("UVMap");
There is this one issue with that part:
//// Error: line 7: Cannot rename uv set to an existing uv set name.
Is one of selected object already has UVMap channel, it won't rename others.
Then I have creating UVLightmap and copying content from UVMap to UVLightmap.
//print("Created 'UVLightmap'");
{string $objects[] = `uvSetMakeSelectCmd`;polyUVSet -create -uvSet "UVLightmap" $objects;};
//{string $objects[] = `uvTkCreateUVSetTargets`;polyUVSet -create -uvSet "UVLightmap" $objects;};
print("Created 'UVLightmap' and copied content from 'UVMap' to 'UVLightmap'");
polyCopyUV -uvSetNameInput "UVMap" -uvSetName "UVLightmap" -ch 1;
So that causes situations of creating UVLightmap1...2.. if UVLightmap already exists.
Atm Part 1 and Part 2+3 I have split under different hotkeys.
Gif shows some of the situations. Generally it works, but requires to go through individual cases manually.
I am after selecting 50 assets and get the same end result.
Therefore also part 4 is needed, where would be performed cleanup from other UV sets than 'UVMap' and 'UVLightmap'.
Many thanks,
DS