博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Maya批量传递UV插件
阅读量:6936 次
发布时间:2019-06-27

本文共 6500 字,大约阅读时间需要 21 分钟。

之前写的关于Maya批量传递UV的小插件。在传递大量模型的UV属性时可用,免得一个一个去Transfer Attribute。列表可编辑,便于多次分步进行模型选择和传递。

英文界面版: 

中文界面版:

附源码:

//The Plug-in of batch UVs Transfer //Script by @Mullin//Date Dec, 14th, 2015string $toSendList[];clear $toSendList;string $unfoldedOBJ;$unfoldedOBJ = "";//Function for the tip and attention windowsglobal proc wrong(int $WrongNum){    string $TextSay = "";        if($WrongNum==1)        $TextSay = "Please select polygon objects.";        if($WrongNum==2)        $TextSay = "Please select one polygon object.";        if($WrongNum==3)        $TextSay = "You haven't selected an unfolded object.";        if($WrongNum==4)        $TextSay = "You haven't selected object(s) to transfer UVs.";            if($WrongNum==5)    $TextSay = "Don't transfer UVs to itself.";        if($WrongNum==0)        $TextSay = "Batch UVs transfer finished.";        if(`window -ex wrong`)        deleteUI wrong;    window -title "Tips" wrong ;        rowColumnLayout -rowAttach 1 "both" 18 -columnAttach 1 "both" 50;        text -label $TextSay;        setParent ..;    showWindow wrong;    window -edit -widthHeight 350 60 -s 0 wrong;}//The command function for the UV_unfolded_OBJ button  global proc loadUVunfolded(){    global string $unfoldedOBJ;        string $selectList[] = `filterExpand -sm 12`;    $numSelect = size ($selectList);    if ($numSelect == 0){        wrong(1);        $unfoldedOBJ = "";    }           if ($numSelect >=2){        wrong(2);        $unfoldedOBJ = "";    }        if ($numSelect == 1){        $unfoldedOBJ = $selectList[0];    }        textField -e -text $unfoldedOBJ loadUnfoldedOBJ;}//The command function for the plus("+") buttonglobal proc listAdd(){    global string $toSendList[];    string $selectList[] = `filterExpand -sm 12`;    $numSelect = size ($selectList);    for($i=0; $i<$numSelect ; ++$i) {        if (stringArrayContains($selectList[$i], $toSendList)==0 ){            stringArrayInsertAtIndex(1, $toSendList, $selectList[$i]);            textScrollList -e -append $selectList[$i] toSendScroll;        }    }    textScrollList -e -deselectAll toSendScroll;    $numToSend = size($toSendList);    string $textInTotal = "objects to transfer UVs ( " + $numToSend + " in total ):";    text -e -label $textInTotal textTotal;    scriptJob -e "SelectionChanged" "highlightSelected";}//The command function for the remove("-") buttonglobal proc listSub(){    global string $toSendList[];    //the selection from the list to the scene     select -r `textScrollList -query -selectItem toSendScroll`;    string $selectList[] = `filterExpand -sm 12`;    //remove the item from the list and the array     $toSendList = stringArrayRemove($selectList,$toSendList);    $numSelect = size($selectList);    for($i=0; $i<$numSelect ; ++$i) {        textScrollList -e -removeItem $selectList[$i] toSendScroll;    }    $numToSend = size($toSendList);    string $textInTotal = "objects to transfer UVs ( " + $numToSend + " in total ):";    text -e -label $textInTotal textTotal;}//The "Clear" button functionglobal proc listClear(){     global string $toSendList[];     clear $toSendList;     textScrollList -e -removeAll toSendScroll;     text -e -label "objects to transfer UVs ( 0 in total ):" textTotal;}//Use the scriptJob to highlight the item selected from the scene,//which makes you select the list item more obviouslyglobal proc highlightSelected() {    global string $toSendList[];    string $selectList[] = `filterExpand -sm 12`;    $numSelect = size($selectList);    textScrollList -e -deselectAll toSendScroll;    for ($i=0; $i<$numSelect ; ++$i){        int $found = stringArrayContains($selectList[$i], $toSendList);        if($found) {            textScrollList -e -selectItem $selectList[$i] toSendScroll;        }    }}//The command function of the button "Transfer", the core proc of this plug-inglobal proc transferCommand(){    global string $unfoldedOBJ;    global string $toSendList[];    $numToSend = size($toSendList);    if ($unfoldedOBJ == ""){        wrong(3);        return;    }        if ($numToSend == 0){        wrong(4);        return;    }        for ($i=0; $i<$numToSend; ++$i){        //if you transfer attribute to the object itself,        //Maya will report error and stop the procedure        if ($unfoldedOBJ == $toSendList[$i]){            wrong(5);        }        else {            select -r $unfoldedOBJ ;            select -tgl $toSendList[$i] ;            transferAttributes                 -transferPositions 0                 -transferNormals 0                 -transferUVs 2                 -transferColors 2                 -sampleSpace 4                 -sourceUvSpace "map1"                 -targetUvSpace "map1"                 -searchMethod 3                -flipUVs 0                 -colorBorders 1 ;            wrong(0);        }    }}//To kill the scriptJob SelectionChanged after the window closedglobal proc closeWindow(){    scriptJob -killAll;}//The main window global proc mainWindow_UV_Transfer(){        if(`window -query -exists UV_Transfer`){        deleteUI UV_Transfer;    }window -title "Batch UV Transfer" UV_Transfer;rowColumnLayout    -numberOfColumns 1    -rowAttach 1 "top" 20    -columnAttach 1 "both" 25    -columnWidth 1 300;                  rowColumnLayout        -columnWidth 1 150        -columnWidth 2 100        -numberOfColumns 2;            textField            -text ""            -editable 0            loadUnfoldedOBJ;            button             -label "Load Unfolded"            -c loadUVunfolded;            setParent ..;     separator -height 10 -st "none";    rowColumnLayout;                text -label "Objects to transfer UVs ( 0 in total ):" textTotal;            setParent ..;           textScrollList        -height 270        -allowMultiSelection true        toSendScroll;            rowColumnLayout        -columnWidth 1 100        -columnWidth 2 100        -columnWidth 3 50        -numberOfColumns 3;        button            -label "+"            -c  listAdd;                    button             -label "-"            -c listSub;                    button             -label "Clear"            -c listClear;               setParent ..;        separator  -height 15 -st "none";        button          -label "Transfer"        -c transferCommand;     showWindow UV_Transfer;window     -edit    -widthHeight 300 440     -s 0     UV_Transfer;    scriptJob -uiDeleted UV_Transfer closeWindow -protected;}mainWindow_UV_Transfer;

 

转载于:https://www.cnblogs.com/mullin/p/5095451.html

你可能感兴趣的文章
海量数据处理专题(九)——外排序
查看>>
解决sqlplus的segmentation fault或hang问题
查看>>
企业搜索引擎开发之连接器connector(八)
查看>>
win8下Python学习——搭建web.py框架
查看>>
自动清理手机文件方法
查看>>
【工具类】NetWorkHelper
查看>>
Spring MVC 教程,快速入门,深入分析(转载)
查看>>
财经法规与会计职业道德4
查看>>
php 杂记
查看>>
单元测试同时支持 NUnit/MSTest
查看>>
沟通至上 《高效程序员的45个习惯》读书笔记
查看>>
解决Android中无法搜索联系人的问题
查看>>
使用网站作为WCF服务宿主的几种做法
查看>>
2013ACM多校联合(2)
查看>>
zoom.js:一款效果很独特的页面内容缩放插件
查看>>
GateWay程序分析01_主程序分析
查看>>
POJ 1328
查看>>
程序应用程序PureMvc学习(一)
查看>>
获取元素offset的方法
查看>>
Javascript综合应用小案例
查看>>