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;

 

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

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: Maya是一款强大的三维计算机图形软件,它提供了众多的功能和工具,可以创建和编辑各种类型的三维内容。在使用Maya时,我们经常需要使用插件来扩展其功能。 要批量转换fbx格式文件,我们可以通过安装插件来实现。以下是一种可能的方法: 首先,我们需要找到适合我们需求的批量转换插件。我们可以在Maya插件市场或其他Maya资源网站上搜索相关的插件。选择具有好评和较高评分的插件,以确保其稳定性和可靠性。 一旦我们找到了合适的插件,我们需要下载它并将其安装到Maya软件中。在安装过程中,我们可能需要按照插件提供的指示进行安装步骤。 安装完成后,我们需要在Maya中启用插件。在Maya软件中的“插件管理器”选项中,我们可以找到并启用已安装的插件。 启用插件后,我们可以在Maya的工具栏或菜单中找到插件的功能选项。根据插件的特性和设计,我们可以找到一个特定的选项或工具,用于批量转换fbx格式文件。 此时,我们可以选择要转换的文件或文件夹,并使用插件提供的功能来进行批量转换操作。根据插件的特性,我们可以根据自己的需求进行各种设置和参数调整。 一旦转换完成,我们可以在指定的输出目录中找到转换后的fbx文件。我们可以使用Maya或其他兼容的软件来打开和编辑这些文件。 总结起来,Maya安装插件以实现批量转换fbx格式文件是一种有效的方式。通过选择合适的插件,安装并启用它,我们可以轻松地在Maya中完成这一操作。 ### 回答2: Maya是一款流行的专业3D动画软件,可以用于制作电影、动画片、游戏等。在使用Maya期间,我们可能需要安装各种插件来增强软件的功能。如果想要批量转换FBX格式的文件,我们可以通过以下步骤来安装相关插件。 首先,我们需要找到并下载适用于Maya批量转换插件。可以在Maya官方网站、Maya插件市场或其他第三方网站上找到这些插件。确保下载的插件Maya版本兼容。 一旦下载完成,解压插件文件夹。在Maya插件目录中找到一个称为“Plug-ins”或“脚本”(Scripts)的文件夹,将插件文件夹复制到此处。 接下来,在Maya软件中打开脚本编辑器。选择“窗口”菜单,然后点击“脚本编辑器”选项。脚本编辑器窗口将打开。 在脚本编辑器窗口中,点击“文件”菜单,然后选择“加载脚本”选项。在弹出的对话框中,寻找并选择之前复制的插件文件夹中的脚本文件。点击“打开”按钮。 一旦插件脚本加载完毕,我们可以在Maya插件管理器中找到新安装的插件。选择“窗口”菜单,然后点击“设置/首选项”选项。在下拉菜单中选择“插件管理器”。 插件管理器窗口将弹出,展示已安装的插件列表。在列表中找到刚刚安装的插件,并确保已选中其复选框。点击“加载”按钮以启用插件。 现在,我们可以使用这个插件批量转换FBX格式的文件了。在Maya的菜单栏中选择“文件”菜单,然后点击“批处理”选项。在弹出的下拉菜单中,我们应该能够看到插件的选项。 点击插件选项,根据插件的使用说明来配置和使用它。通常,我们需要选择要转换的文件以及输出的文件路径和格式。 最后,点击插件界面或菜单中的“转换”按钮,插件将开始批量转换所选文件的格式为FBX。 使用以上步骤,我们可以方便地安装和使用Maya插件批量转换文件为FBX格式。插件的功能和使用方法可能因插件的不同而有所差异,以上步骤仅供参考。 ### 回答3: Maya是一款广泛应用于三维动画制作和建模的软件。在Maya中安装插件可以增强软件的功能,使其更适应用户的需求。插件是由第三方开发的,可以提供各种额外的工具和功能。 要在Maya批量转换FBX格式文件,可以通过安装插件来实现。插件中的批量转换工具可以同时转换多个文件,节省了时间和劳动力。 安装插件的步骤如下: 1. 在网上搜索Maya批量转换插件,找到一个可靠且适用于你的版本的插件。确保插件是来自可信任的来源。 2. 下载插件文件,并将其保存到计算机上。 3. 打开Maya软件,进入插件管理器。插件管理器可以在Maya的窗口菜单中找到。 4. 在插件管理器中,点击"浏览"按钮,选择你下载的插件文件。 5. 点击"加载"按钮,Maya会加载并安装插件。如果插件安装成功,你将在插件列表中看到插件的名称。 6. 关闭插件管理器,重新启动Maya软件。 安装完插件后,你将在Maya的工具栏或菜单中找到一个新的批量转换工具。打开该工具后,你可以选择要转换的文件夹或文件列表,然后选择需要转换的目标格式,如FBX。 接下来,你可以点击开始转换按钮,插件会自动按照你的设定批量转换文件。转换完成后,你将得到一批转换好的FBX格式文件。 通过安装插件来实现Maya批量转换FBX格式文件,可以提高工作效率,简化操作流程。这样的工具在需要将大量文件转换格式或将项目导出给其他软件时尤其有用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值