Maya批量传递UV插件

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

英文界面版: http://pan.baidu.com/s/1o7fYgsU

中文界面版:http://pan.baidu.com/s/1gdUbgJp

附源码:

//The Plug-in of batch UVs Transfer
//Script by @Mullin
//Date Dec, 14th, 2015

string $toSendList[];
clear $toSendList;
string $unfoldedOBJ;
$unfoldedOBJ = "";

//Function for the tip and attention windows
global 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("+") button
global 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("-") button
global 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 function
global 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 obviously
global 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-in
global 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 closed
global 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;
时间: 2024-10-20 06:54:29

Maya批量传递UV插件的相关文章

框架 day50 BOS项目 4 批量导入(ocupload插件,pinyin4J)/POI解析Excel/Combobox下拉框/分区组合条件分页查询(ajax)/分区数据导出(Excel)

知识点: 批量导入(ocupload插件,pinyin4J /POI解析Excel(apache POI) /区域分页查询 /Combobox下拉框 /分区组合条件分页查询(ajax) /分区数据导出(Excel下载) BOS项目笔记第4天 1.    区域批量导入功能 *Ajax不支持文件上传. *上传并且不刷新上传页面原理: Target到一个0,0,0的隐藏iframe里,造成一个没有刷新的假象 <form target="myIframe" action="ab

SWFUpload批量上传插件

SWFUpload是一个批量上传插件,在HTML4.1里面,估计也只有Flash+javascript配合才能够做到了.先复制个重要的网址,这个应该是官方的文档了,相当齐全. http://leeon.me/upload/other/swfupload.html#uploadStart 这个是格式比较好看的. http://www.cnblogs.com/2050/archive/2012/08/29/2662932.html 算了,这个文档的内容太多,各种属性各种方法,记不了这么多,直接贴上个

基于jQuery很牛X的批量上传插件

上传功能应该是每个网站必备的工具之一,因此出现了出现了很多各式各样的上传插件! 本文基于个人经验和使用从插件的:交互体验,易用性,文档,美观度出发,为大家推荐三款很NX的批量上传插件! 下面三款插件的特点:1.简单易配置,2.带进度条上传,3.可批量上传自定义格式文件 1.jQuery File Upload 官网:http://blueimp.github.com/jQuery-File-Upload/ 在线示例:http://blueimp.github.com/jQuery-File-Up

绑定后想要把 分好uv的物体传递uv给 绑定好的物体.

绑定后传递uv要使用 polyTransfer 命令 polyTransfer [-alternateObject string] [-caching boolean] [-constructionHistory boolean] [-name string] [-nodeState int] [-uvSets boolean] [-vertexColor boolean] [-vertices boolean] Transfer information from one polygonal o

Activity之间利用intent单个传递数据和批量传递数据

1.利用intent传递数据,若是单个传递数据时,利用putExtra即可完成传递 intent.putExtra("tel", "15607209140");//单个数据传递 Bundle b=new Bundle(); b.putString("name1", "zp"); b.putString("name2", "db");//批量传递数据 intent.putExtras(b)

Grunt中批量无损压缩图片插件--Grunt-contrib-imagemin

Photoshop 切出的图片,无论是 PNG 还是 JPEG/JPG 格式,都含有许多相关信息,又或多余的颜色值,这些信息和颜色值,对网页前端并没有用处,反而增加图片大小,所以 Google Pagespeed 最佳实践建议我们用 jpegtran 或 jpegoptim (仅限 Linux 平台) 对 jpeg/jpg 图片进行无损压缩,如果是 PNG 格式,则使用 OptiPNG 或 PNGOUT 压缩.减小图片大小,就可以减少用户下载的文件大小,加快页面访问速度. 不过上面提到的几个工具

带进度条的文件批量上传插件uploadify

有时项目中需要一个文件批量上传功能时,个人认为uploadify是快速简便的解决方案. 先上效果图: 一. 下载uploadify 从官网下载uploadify的Flash版本(Flash版本免费,另一版本HTML5版本需要付费) 下载地址: http://www.uploadify.com/download/ 下载后直接把文件解压,然后放在项目中 二. 在项目中使用 在页面中引入: <!--引入Jquery--> <script src="js/jquery-1.11.3.m

Grunt中批量无损压缩图片插件--grunt-sprite

这是什么 这是一个帮助前端开发工程师将css代码中的切片合并成雪碧图的工具,它的主要功能是: 使用二叉树排列算法,对css文件进行处理,收集切片序列,生成雪碧图 在原css代码中为切片添加background-position属性 生成用于高清设备的高清雪碧图,并在css文件末尾追加媒体查询代码 在引用雪碧图的位置打上时间戳 在样式末尾追加时间戳 安装依赖 grunt-sprite 使用 spritesmith 作为内部核心算法,根据官方文档中提到的基本依赖,须要安装Graphics Magic

@半条_虫 淘宝天猫自动批量打旗帜插件,精准打旗解放双手

/* * * 淘宝天猫批量打旗帜工具 Beta 1.0.0.0 * Release date: * Author : 半条虫(466814195) * Keywords : Etsoftware 半条虫(466814195) rimke 39doo 39度 * Description : 本脚本功能由EtSoftWare团队研发,仅供学习不得用于商业用途. * Blog : http://rimke.blog.163.com/ * Website : http://www.39doo.com/