Maya-UV zTool
2024年7月7日
The new version combines the previous UVset and UVTransfer tools and adds a list of UV sets
New version
Logs:
2024-9-22: 改进了一下交换命令后刷新uvlist,已确定切换显示正常。
Code-view
UVztool.py
import maya.cmds as cmds
# 定义窗口的最小宽度和高度
MIN_WINDOW_WIDTH = 200
MIN_WINDOW_HEIGHT = 300
# 函数:获取并显示UV集
def refresh_uv_sets():
selection = cmds.ls(selection=True)
if not selection:
cmds.warning("请先选择一个物体。")
return
selected_object = selection[0]
uv_sets = cmds.polyUVSet(selected_object, query=True, allUVSets=True)
cmds.textScrollList('uvList', edit=True, removeAll=True)
for uv_set in uv_sets:
cmds.textScrollList('uvList', edit=True, append=uv_set)
# 函数:切换UV集
def switch_uv_set(*args):
selected_uv_set = cmds.textScrollList('uvList', query=True, selectItem=True)
if selected_uv_set:
selected_object = cmds.ls(selection=True)
if selected_object:
selected_object = selected_object[0]
# 切换当前 UV 集
cmds.polyUVSet(selected_object, currentUVSet=True, uvSet=selected_uv_set[0])
print(f"切换到 UV 集:{selected_uv_set[0]}")
else:
cmds.warning("请选择一个物体。")
else:
cmds.warning("请选择一个 UV 集。")
# 函数:删除选中的UV集
def delete_selected_uv_set():
selected_uv_set = cmds.textScrollList('uvList', query=True, selectItem=True)
if selected_uv_set:
cmds.polyUVSet(delete=True, uvSet=selected_uv_set[0])
refresh_uv_sets()
# 函数:重命名选中的UV集
def rename_selected_uv_set(new_name):
selected_uv_set = cmds.textScrollList('uvList', query=True, selectItem=True)
if selected_uv_set:
if new_name:
cmds.polyUVSet(rename=True, newUVSet=new_name, uvSet=selected_uv_set[0])
refresh_uv_sets()
cmds.textFieldGrp('newNameField', edit=True, text='') # 清空输入框内容
else:
cmds.warning("请输入新名称。")
else:
cmds.warning("请先选择一个 UV 集。")
# 函数:新建UV集
def create_new_uv_set(new_name):
if new_name:
cmds.polyUVSet(create=True, uvSet=new_name)
refresh_uv_sets()
cmds.textFieldGrp('newNameField', edit=True, text='') # 清空输入框内容
else:
cmds.warning("请输入新 UV 集的名称。")
# 函数:设置 UV 集 1 名称
def set_uv_set1_name(*args):
selected_uv_set = cmds.textScrollList('uvList', query=True, selectItem=True)
if selected_uv_set:
cmds.textFieldGrp("uvSet1", edit=True, text=selected_uv_set[0])
else:
cmds.warning("请先选择一个 UV 集。")
# 函数:设置 UV 集 2 名称
def set_uv_set2_name(*args):
selected_uv_set = cmds.textScrollList('uvList', query=True, selectItem=True)
if selected_uv_set:
cmds.textFieldGrp("uvSet2", edit=True, text=selected_uv_set[0])
else:
cmds.warning("请先选择一个 UV 集。")
# 函数:UV集 交换
def UVsetSwap(*args):
UVname1 = cmds.textFieldGrp("uvSet1", query=True, text=True)
UVname2 = cmds.textFieldGrp("uvSet2", query=True, text=True)
cmds.polyUVSet(query=True, allUVSets=True)
cmds.polyUVSet(create=True, uvSet='TempUV')
cmds.polyUVSet(copy=True, nuv='TempUV', uvSet=UVname1)
cmds.polyUVSet(copy=True, nuv=UVname1, uvSet=UVname2)
cmds.polyUVSet(copy=True, nuv=UVname2, uvSet='TempUV')
cmds.polyUVSet(delete=True, uvSet='TempUV')
refresh_uv_sets() # 执行后刷新列表
def UVsetReorder(*args):
UVname1 = cmds.textFieldGrp("uvSet1", query=True, text=True)
UVname2 = cmds.textFieldGrp("uvSet2", query=True, text=True)
print("Reorder object is " + UVname1 + " + " + UVname2)
cmds.polyUVSet(reorder=True, uvSet=UVname1, newUVSet=UVname2)
UVobj = cmds.ls(sl=True)
cmds.select(UVobj)
refresh_uv_sets() # 执行后刷新列表
# 函数:UV集 对调
def get_object_name(*args):
# 获取当前选中的对象并将其名称填入文本字段
selected = cmds.ls(sl=True)
if selected:
cmds.textField('objectNameField', edit=True, text=selected[0])
else:
cmds.warning("没有选中任何对象。")
def set_uv(*args):
# 获取源对象和目标对象,执行UV传递,并清理历史记录
source_object = cmds.textField('objectNameField', query=True, text=True)
target_object = cmds.ls(sl=True)
if not source_object or not target_object:
cmds.warning("请确保已经选择了源对象和目标对象。")
return
target_object = target_object[0]
sample_space_dict = {'世界': 0, '局部': 1, 'UV': 5, '组件': 4}
sample_space = cmds.radioCollection('sampleSpaceRadio', query=True, select=True)
sample_space = cmds.radioButton(sample_space, query=True, label=True)
sample_space = sample_space_dict.get(sample_space, 0)
cmds.transferAttributes(source_object, target_object, transferPositions=0, transferNormals=0, transferUVs=2, transferColors=0, sampleSpace=sample_space, searchMethod=3)
cmds.delete(target_object, constructionHistory=True) # 清理历史记录
def on_window_resize(*args):
# 获取当前窗口大小
current_width = cmds.window('uvTransferWindow', query=True, width=True)
current_height = cmds.window('uvTransferWindow', query=True, height=True)
# 检查并限制窗口大小
if current_width < MIN_WINDOW_WIDTH:
cmds.window('uvTransferWindow', edit=True, width=MIN_WINDOW_WIDTH)
if current_height < MIN_WINDOW_HEIGHT:
cmds.window('uvTransferWindow', edit=True, height=MIN_WINDOW_HEIGHT)
if cmds.window('uvTransferWindow', exists=True):
# 如果窗口已经存在,先删除它
cmds.deleteUI('uvTransferWindow', window=True)
# Window
# 创建一个新的窗口,并设置其标题和初始大小
window = cmds.window('uvTransferWindow', title="UV zTool", widthHeight=(MIN_WINDOW_WIDTH, MIN_WINDOW_HEIGHT), sizeable=True, tlb=True) # tlb=True
cmds.frameLayout(label='UV-Set')
cmds.columnLayout(adjustableColumn=True)
# 创建一个 textScrollList 控件,并设置选择改变的命令
cmds.textScrollList('uvList', numberOfRows=8, allowMultiSelection=False, width=120, selectCommand=switch_uv_set)
cmds.textFieldGrp('newNameField', placeholderText=' 输入新名称后,点击下方Re重命名', width=120,columnAlign=[1, 'center'] ,columnWidth=[1,250])
cmds.rowLayout(numberOfColumns=4,
columnWidth4=(55, 55, 55, 55),
columnAttach4=('both', 'both', 'both', 'both'))
cmds.button( label='Get', height=32, command=lambda x: refresh_uv_sets(),backgroundColor=(0.87, 0.19, 0.39))
cmds.button( label='Del', height=32, command=lambda x: delete_selected_uv_set())
cmds.button( label='New', height=32, command=lambda x: create_new_uv_set(cmds.textFieldGrp('newNameField', query=True, text=True)))
cmds.button( label='Re', height=32, command=lambda x: rename_selected_uv_set(cmds.textFieldGrp('newNameField', query=True, text=True)))
cmds.setParent( '..' )
cmds.setParent('..') # 结束当前的表单布局
cmds.frameLayout(label='UV-Swap')
cmds.columnLayout(adjustableColumn=True, width=110)
cmds.text(l='在“uv1”和“uv2”中输入uvSet名称', h=15)
cmds.text(l=' UV对调或排序对调. ', h=15)
cmds.text(l='', h=5)
cmds.rowLayout(numberOfColumns=3, columnWidth3=(55, 55, 55), columnAttach3=('both', 'both', 'both'))
cmds.button(label='Get', height=25, command=set_uv_set1_name, backgroundColor=(0.87, 0.19, 0.39))
cmds.textFieldGrp("uvSet1", placeholderText='uv1', editable=True, width=120)
cmds.setParent('..')
cmds.rowLayout(numberOfColumns=3, columnWidth3=(55, 55, 55), columnAttach3=('both', 'both', 'both'))
cmds.button(label='Get', height=25, command=set_uv_set2_name, backgroundColor=(0.87, 0.19, 0.39))
cmds.textFieldGrp("uvSet2", placeholderText='uv2', editable=True, width=120)
cmds.setParent('..')
cmds.rowColumnLayout(numberOfColumns=2, columnWidth=[(1, 120), (2, 120)])
cmds.button(label='UV对调', command=UVsetSwap, backgroundColor=(0.87, 0.19, 0.39))
cmds.button(label='排序对调', command=UVsetReorder, backgroundColor=(0.87, 0.19, 0.39))
UVname1 = cmds.textFieldGrp("uvSet1", query=True, text=True)
UVname2 = cmds.textFieldGrp("uvSet2", query=True, text=True)
print("Now we have UVset = {}, {}".format(UVname1, UVname2))
cmds.setParent('..') # 结束当前的表单布局
# 分隔符
cmds.separator(height=20, style='in')
# 创建一个列布局,所有的子元素都会垂直排列
cmds.frameLayout(label='UV-Transfer')
cmds.columnLayout(adjustableColumn=True, width=230, height=130)
cmds.rowLayout(numberOfColumns=3, columnWidth3=(50, 100, 50))
cmds.button(label='Get', command=get_object_name, backgroundColor=(0.87, 0.19, 0.39), width=45) # 创建一个按钮,点击时调用 get_object_name 函数
cmds.textField('objectNameField', enable=False, width=120) # 创建一个文本字段,用于显示选中的对象的名称
cmds.button(label='Set', command=set_uv, backgroundColor=(0.87, 0.19, 0.39), width=45) # 创建一个按钮,点击时调用 set_uv 函数
cmds.setParent('..') # 结束当前的表单布局
# cmds.frameLayout(label='采样空间')
cmds.text(l='采样空间:', h=20, align='left')
form = cmds.formLayout()
cmds.radioCollection('sampleSpaceRadio') # 创建一个单选按钮组
rb1 = cmds.radioButton(label='世界', select=True) # 创建一个单选按钮
rb2 = cmds.radioButton(label='局部')
rb3 = cmds.radioButton(label='UV')
rb4 = cmds.radioButton(label='组件')
# 设置表单布局的参数,使得单选按钮在窗口大小变化时始终保持横向排列并居中
cmds.formLayout(form, edit=True, attachForm=[(rb1, 'left', 10), (rb4, 'right', 10)], attachControl=[(rb2, 'left', 5, rb1), (rb3, 'left', 5, rb2), (rb4, 'left', 5, rb3)])
cmds.setParent('..') # 结束当前的表单布局
# 分隔符
cmds.separator(height=10, style='in')
# 添加作者信息
cmds.columnLayout(adjustableColumn=True)
cmds.text(label='Megestus', height=20, align='right')
cmds.button(label='https://megestus.github.io/blog', height=20, command=lambda *args: open_url('https://megestus.github.io/blog/posts/maya/UVzTool.html'), )
cmds.setParent('..')
cmds.scriptJob(event=["idle", on_window_resize], parent=window) # 监听窗口调整大小事件
cmds.showWindow(window) # 显示窗口
Old version
uvTransferTool
Get object 1U directly and pass it to the second object
Code-view
python3
import maya.cmds as cmds
def get_object_name(*args):
# 获取当前选中的对象并将其名称填入文本字段
selected = cmds.ls(sl=True)
if selected:
cmds.textField('objectNameField', edit=True, text=selected[0])
else:
cmds.warning("没有选中任何对象。")
def set_uv(*args):
# 获取源对象和目标对象,执行UV传递,并清理历史记录
source_object = cmds.textField('objectNameField', query=True, text=True)
target_object = cmds.ls(sl=True)
if not source_object or not target_object:
cmds.warning("请确保已经选择了源对象和目标对象。")
return
target_object = target_object[0]
sample_space_dict = {'世界': 0, '局部': 1, 'UV': 5, '组件': 4}
sample_space = cmds.radioCollection('sampleSpaceRadio', query=True, select=True)
sample_space = cmds.radioButton(sample_space, query=True, label=True)
sample_space = sample_space_dict.get(sample_space, 'World')
cmds.transferAttributes(source_object, target_object, transferPositions=0, transferNormals=0, transferUVs=2, transferColors=0, sampleSpace=sample_space, searchMethod=3) #执行UV传递
cmds.delete(target_object, constructionHistory=True)#清理历史记录
if cmds.window('uvTransferWindow', exists=True):
# 如果窗口已经存在,先删除它
cmds.deleteUI('uvTransferWindow', window=True)
# 创建一个新的窗口,并设置其标题和初始大小
window = cmds.window('uvTransferWindow', title="UV Transfer Tool", widthHeight=(200, 100),tlb=True)
# 创建一个列布局,所有的子元素都会垂直排列
cmds.columnLayout(adjustableColumn=True, width=230, height=100)
# 创建一个行布局,其中包含三个元素:两个按钮和一个文本字段
cmds.rowLayout(numberOfColumns=3, columnWidth3=(50, 100, 50), )
cmds.button(label='Get', command=get_object_name, backgroundColor=(1,0.5,0.5),width=45 ) # 创建一个按钮,点击时调用 get_object_name 函数
cmds.textField('objectNameField', enable=False,width=120 ) # 创建一个文本字段,用于显示选中的对象的名称
cmds.button(label='Set', command=set_uv, backgroundColor=(1,0.5,0.5), width=45) # 创建一个按钮,点击时调用 set_uv 函数
cmds.setParent('..') # 结束当前的行布局
# 创建一个分隔符
cmds.separator(height=20, style='in')
cmds.frameLayout( label='采样空间' )
# 创建一个表单布局,用于精确控制其子元素的位置
form = cmds.formLayout()
cmds.radioCollection('sampleSpaceRadio') # 创建一个单选按钮组
rb1 = cmds.radioButton(label='世界', select=True) # 创建一个单选按钮
rb2 = cmds.radioButton(label='局部') # 创建一个单选按钮
rb3 = cmds.radioButton(label='UV') # 创建一个单选按钮
rb4 = cmds.radioButton(label='组件') # 创建一个单选按钮
# 设置表单布局的参数,使得单选按钮在窗口大小变化时始终保持横向排列并居中
cmds.formLayout(form, edit=True, attachForm=[(rb1, 'left', 10), (rb4, 'right', 10)], attachControl=[(rb2, 'left', 5, rb1), (rb3, 'left', 5, rb2), (rb4, 'left', 5, rb3)])
cmds.setParent('..') # 结束当前的表单布局
cmds.showWindow(window) # 显示窗口
uvSwapTool
Switch or swap two UV sets
Code-view
python2.8
import maya.cmds as cmds
name = "UVswap"
if cmds.window(name,query=True,exists=True,):
cmds.deleteUI(name)
cmds.window(name,resizeToFitChildren=True)
cmds.columnLayout()
cmds.text(l ='Enter the uvSet name in uv1 and uv2',h=10)
cmds.text(l =' to swap or reorder. ',h=10)
cmds.text(l ='',h=5)
cmds.text(l ='UV1',h=10)
cmds.textFieldGrp( "uvSet1", text='map1' , editable=True)
cmds.text(l ='UV2',h=10)
cmds.textFieldGrp( "uvSet2", text='uvSet', editable=True)
cmds.button(label='UVsetSwap', command='UVsetSwap()')
cmds.text(l ='',h=2)
cmds.button(label='UVsetReorder', command='UVsetReorder()')
cmds.showWindow()
UVname1 = cmds.textFieldGrp( "uvSet1",query=True,text=True)
UVname2 = cmds.textFieldGrp( "uvSet2",query=True,text=True)
print "Now we have UVset = " + UVname1,UVname2
def UVsetSwap():
UVname1 = cmds.textFieldGrp( "uvSet1",query=True,text=True)
UVname2 = cmds.textFieldGrp( "uvSet2",query=True,text=True)
cmds.polyUVSet( query=True, allUVSets=True )
cmds.polyUVSet( create=True, uvSet='TempUV' )
cmds.polyUVSet( copy=True, nuv='TempUV', uvSet=UVname1 )
cmds.polyUVSet( copy=True, nuv=UVname1, uvSet=UVname2 )
cmds.polyUVSet( copy=True, nuv=UVname2, uvSet='TempUV' )
cmds.polyUVSet( delete=True, uvSet='TempUV')
def UVsetReorder():
UVname1 = cmds.textFieldGrp( "uvSet1",query=True,text=True)
UVname2 = cmds.textFieldGrp( "uvSet2",query=True,text=True)
print "Reorder object is " + UVname1 + " + " + UVname2
cmds.polyUVSet( reorder=True, nuv=UVname1, uvSet=UVname2)
UVobj = cmds.ls(sl=1)
cmds.select(UVobj)
python3
import maya.cmds as cmds
# 定义窗口的最小宽度和高度
MIN_WINDOW_WIDTH = 200
MIN_WINDOW_HEIGHT = 250
# uv swap set model
def UVsetSwap(*args):
UVname1 = cmds.textFieldGrp("uvSet1", query=True, text=True)
UVname2 = cmds.textFieldGrp("uvSet2", query=True, text=True)
cmds.polyUVSet(query=True, allUVSets=True)
cmds.polyUVSet(create=True, uvSet='TempUV')
cmds.polyUVSet(copy=True, nuv='TempUV', uvSet=UVname1)
cmds.polyUVSet(copy=True, nuv=UVname1, uvSet=UVname2)
cmds.polyUVSet(copy=True, nuv=UVname2, uvSet='TempUV')
cmds.polyUVSet(delete=True, uvSet='TempUV')
def UVsetReorder(*args):
UVname1 = cmds.textFieldGrp("uvSet1", query=True, text=True)
UVname2 = cmds.textFieldGrp("uvSet2", query=True, text=True)
print("Reorder object is " + UVname1 + " + " + UVname2)
cmds.polyUVSet(reorder=True, uvSet=UVname1, newUVSet=UVname2)
UVobj = cmds.ls(sl=True)
cmds.select(UVobj)
# uvTransfer model
def get_object_name(*args):
# 获取当前选中的对象并将其名称填入文本字段
selected = cmds.ls(sl=True)
if selected:
cmds.textField('objectNameField', edit=True, text=selected[0])
else:
cmds.warning("没有选中任何对象。")
def set_uv(*args):
# 获取源对象和目标对象,执行UV传递,并清理历史记录
source_object = cmds.textField('objectNameField', query=True, text=True)
target_object = cmds.ls(sl=True)
if not source_object or not target_object:
cmds.warning("请确保已经选择了源对象和目标对象。")
return
target_object = target_object[0]
sample_space_dict = {'世界': 0, '局部': 1, 'UV': 5, '组件': 4}
sample_space = cmds.radioCollection('sampleSpaceRadio', query=True, select=True)
sample_space = cmds.radioButton(sample_space, query=True, label=True)
sample_space = sample_space_dict.get(sample_space, 0)
cmds.transferAttributes(source_object, target_object, transferPositions=0, transferNormals=0, transferUVs=2, transferColors=0, sampleSpace=sample_space, searchMethod=3)
cmds.delete(target_object, constructionHistory=True) # 清理历史记录
def on_window_resize(*args):
# 获取当前窗口大小
current_width = cmds.window('uvTransferWindow', query=True, width=True)
current_height = cmds.window('uvTransferWindow', query=True, height=True)
# 检查并限制窗口大小
if current_width < MIN_WINDOW_WIDTH:
cmds.window('uvTransferWindow', edit=True, width=MIN_WINDOW_WIDTH)
if current_height < MIN_WINDOW_HEIGHT:
cmds.window('uvTransferWindow', edit=True, height=MIN_WINDOW_HEIGHT)
if cmds.window('uvTransferWindow', exists=True):
# 如果窗口已经存在,先删除它
cmds.deleteUI('uvTransferWindow', window=True)
# Window
# 创建一个新的窗口,并设置其标题和初始大小
window = cmds.window('uvTransferWindow', title="UV Transfer Tool", widthHeight=(MIN_WINDOW_WIDTH, MIN_WINDOW_HEIGHT), sizeable=True, tlb=True) # tlb=True
# 创建一个列布局,所有的子元素都会垂直排列
cmds.frameLayout(label='UV-Transfer')
cmds.columnLayout(adjustableColumn=True, width=230, height=100)
cmds.rowLayout(numberOfColumns=3, columnWidth3=(50, 100, 50))
cmds.button(label='Get', command=get_object_name, backgroundColor=(0.87, 0.19, 0.39), width=45) # 创建一个按钮,点击时调用 get_object_name 函数
cmds.textField('objectNameField', enable=False, width=120) # 创建一个文本字段,用于显示选中的对象的名称
cmds.button(label='Set', command=set_uv, backgroundColor=(0.87, 0.19, 0.39), width=45) # 创建一个按钮,点击时调用 set_uv 函数
cmds.setParent('..') # 结束当前的表单布局
# cmds.frameLayout(label='采样空间')
cmds.text(l='采样空间:', h=20, align='left')
form = cmds.formLayout()
cmds.radioCollection('sampleSpaceRadio') # 创建一个单选按钮组
rb1 = cmds.radioButton(label='世界', select=True) # 创建一个单选按钮
rb2 = cmds.radioButton(label='局部')
rb3 = cmds.radioButton(label='UV')
rb4 = cmds.radioButton(label='组件')
# 设置表单布局的参数,使得单选按钮在窗口大小变化时始终保持横向排列并居中
cmds.formLayout(form, edit=True, attachForm=[(rb1, 'left', 10), (rb4, 'right', 10)], attachControl=[(rb2, 'left', 5, rb1), (rb3, 'left', 5, rb2), (rb4, 'left', 5, rb3)])
cmds.setParent('..') # 结束当前的表单布局
# 分隔符
cmds.separator(height=20, style='in')
cmds.frameLayout(label='UV-Swap')
cmds.columnLayout(adjustableColumn=True, width=110)
cmds.text(l='Enter the uvSet name in uv1 and uv2', h=10)
cmds.text(l=' to swap or reorder. ', h=10)
cmds.text(l='', h=5)
cmds.text(l='UV1', h=10)
cmds.textFieldGrp("uvSet1", text='map1', editable=True, width=120)
cmds.text(l='UV2', h=10)
cmds.textFieldGrp("uvSet2", text='uvSet', editable=True, width=120)
cmds.rowColumnLayout(numberOfColumns=2, columnWidth=[(1, 100), (2, 100)])
cmds.button(label='UVsetSwap', command=UVsetSwap, backgroundColor=(0.87, 0.19, 0.39))
cmds.button(label='UVsetReorder', command=UVsetReorder, backgroundColor=(0.87, 0.19, 0.39))
UVname1 = cmds.textFieldGrp("uvSet1", query=True, text=True)
UVname2 = cmds.textFieldGrp("uvSet2", query=True, text=True)
print("Now we have UVset = {}, {}".format(UVname1, UVname2))
cmds.setParent('..') # 结束当前的表单布局
cmds.scriptJob(event=["idle", on_window_resize], parent=window) # 监听窗口调整大小事件
cmds.showWindow(window) # 显示窗口
mayaUVswap.mel
proc lbUvsetreorder()
{
string $lbText1 = `textFieldGrp -q -tx text1n`;
string $lbText2 = `textFieldGrp -q -tx text2n`;
//Get the input text
string $LUVSet1 = $lbText1;
string $LUVSet2 = $lbText2;
//Set a variable
string $curObjList[] = `ls -sl` ;
polyUVSet -reorder -uvSet $LUVSet1 -nuv $LUVSet2;//reorder uv1 and uv2
select $curObjList ;
}
proc lbUvsetswap0()
{
string $lbText1 = `textFieldGrp -q -tx text1n`;//查询输入框内的文本名字
string $lbText2 = `textFieldGrp -q -tx text2n`;
//Get the input text 获得输入的文本名字
string $LUVSet1 = $lbText1;
string $LUVSet2 = $lbText2;
//Set a variable 获得变量
string $curObjList[] = `ls -sl` ;
string $curObj;
for ($i = 0; $i < size($curObjList); $i++) {
// store original current UV set for later
string $originalUVset[] = `polyUVSet -q -currentUVSet $curObjList[$i]`;
// check for mapl and uvSet. Error if they don't exist
polyUVSet -currentUVSet -uvSet $LUVSet1 $curObjList[$i];
string $checkUVmapl[] = `polyUVSet -q -currentUVSet $curObjList[$i]`;
if ($checkUVmapl[0] == $LUVSet1) { // If it exists, do nothing
print "\n mapl exists \n";
} else {// If it doesn't exist, error
error "Missing UV set:First uvSet" ;
}
polyUVSet -currentUVSet -uvSet $LUVSet2 $curObjList[$i];
string $checkUVset2[] = `polyUVSet -q -currentUVSet $curObjList[$i]`;
print "\n uvSet exists \n";
if ($checkUVset2[0] == $LUVSet2) {// If it exists, do nothing
} else { // If it doesn't exist, error
error "Missing UV set:Second uvSet" ;
}
// check for and make a temp UV set
polyUVSet -currentUVSet -uvSet "tempUV" $curObjList[$i];
string $checkUVtemp[] = `polyUVSet -q -currentUVSet $curObjList[$i]`;
if ($checkUVtemp[0] == "tempUV") {// If it exists, don't make it
polyUVSet -currentUVSet -uvSet $LUVSet1 $curObjList[$i];
polyUVSet -copy -uvSet $LUVSet1 -nuv "tempUV" $curObjList[$i];// copy "mapl" UVs to "tempUV"
} else {// If it doesn't exist, make it
polyUVSet -create -uvSet "tempUV" $curObjList[$i];
polyUVSet -copy -uvSet $LUVSet1 -nuv "tempUV" $curObjList[$i];// copy "mapl" UVs to "tempUV"
}
polyUVSet -copy -uvSet $LUVSet2 -nuv $LUVSet1 $curObjList[$i];// copy "tempUV" UVs to "mapl"
polyUVSet -copy -uvSet "tempUV" -nuv $LUVSet2 $curObjList[$i];// copy "uvSet" UVs to "uvSet"
polyUVSet -delete -uvSet "tempUV" $curObjList [$i]; // delete the temp UV set
string $restoreUVset = $originalUVset[0];
polyUVSet -currentUVSet -uvSet $restoreUVset $curObjList[$i];
}
print "\n UV set swap first uvSet <-> second uvSet Done \n";
select $curObjList ;
// check for and make a temp UV set
// copy mapl to a temp UV set
// copy uvSet to mapl
// copy temp uv set to mapl
// delete temp uv set
}
///////////////UI///////////////////
proc lbUVsetSwapwin()
{
string $lbwindows0 = "UVsetSwap";
if(`window -ex $lbwindows0`)
{
deleteUI -window $lbwindows0;
windowPref -remove -ra $lbwindows0;
}
if(!`window -ex $lbwindows0`)
{
string $lbWinName0 = `window -tlb 1 $lbwindows0`;
columnLayout;
text -label " Enter the uvSet name in uv1 and uv2 " ;
text " to swap or reorder. ";
text " ";
text "uv1";
textFieldGrp -tx "map1" text1n;
text "uv2";
textFieldGrp -tx "uvSet" text2n;
button -l "UVset Swap" -h 30 -c lbUvsetswap0;
button -l "UVset Reorder" -h 30 -c lbUvsetreorder;
setParent ..;
showWindow $lbwindows0;
}
}
lbUVsetSwapwin();