首页 > 解决方案 > followObject_Setup 和 followObjectExpr 在这里是什么意思

问题描述

我是 Maya 脚本的新手,我被要求将以下 MEL 转换为 Python。

我一直在搜索 Mel 中的所有命令,一切似乎都很好,除了下面脚本中的两个术语 ## followObject_setup 和 followObjectExpr ##。

谁能解释一下,这是什么。

提前致谢

global proc newPointBlast_Follow()
{
/*
    Function to get the point from selection and camera from view.
    Attach the camera to point.
*/
global string $followingCamera[];
global string $object_to_Follow[];

undoInfo -swf off;

string $currentPanel = `getPanel -wf`;
string $type = `getPanel -typeOf $currentPanel`;
if ( $type == "modelPanel" ) 
    { 
        $followingCamera[0]  = `modelPanel -q -camera $currentPanel`; 
    }

$object_to_Follow = `ls -sl`;
if ( `size( $object_to_Follow )` == 0 ) 
    { 
        confirmDialog -title "No Object selected" -message "Please select an Object or Vertex to Follow" -button "OK"; }

else
{
    newPointBlast_unlockImagePlanes();

    if ( `objExists followObject_setup` )
    {
            delete followObject_setup;
    }
    if ( `objExists followObjectExpr` )
    {
            delete followObjectExpr;
    }

最后一个 if 语句的含义是什么?

标签: pythonmayamel

解决方案


它是在其他地方定义的一些变量。

在 Maya 中,如果您输入 MEL :

whatIs followObjectExpr
whatIs followObject_setup

如果它返回 None,它不是一个 proc 或属于 Maya 的东西

否则,如果你不能在 python 中粗略地转换你的命令,你可以使用下面的命令来转换一个 mel 字符串:

import pymel.tools.mel2py as mel2py
text = raw_input()
print(mel2py.mel2pyStr(text, pymelNamespace='pm'))

或者您可以使用它来转换 mel 文件:

import pymel.tools.mel2py as mel2py

mel2py.mel2py('/path/maya20XX/scripts/others/doWrapArgList.mel',
                '/path/myfolder/doWrapArgList/')

推荐阅读