通过proc传递字符串数组

时间:2017-08-08 14:17:13

标签: arrays scripting global maya mel

这是我在MEL中的代码,但我不知道为什么它没有运行:

window -width 150;
columnLayout -adjustableColumn true;
    button -label "Button 1" -command "Base";
    button -label "Button 2" -command "Top";
    button -label "Button 3" -command "test";
showWindow;

global string $BaseCurves, $TopCurves;

global proc Base () {
    $BaseCurves=`ls -sl`;
}

global proc Top () {
    $TopCurves=`ls -sl`;
}

global proc test () {
    print $TopCurves[0];
}

我不知道为什么会出现这个错误:

"$TopCurves" is an undeclared variable.

1 个答案:

答案 0 :(得分:0)

试试这个:

global string $BaseCurves;

window -width 150;
columnLayout -adjustableColumn true;
    button -label "Button 1" -command "Base";
    button -label "Button 2" -command "Top";
    button -label "Button 3" -command "test";
showWindow;

global proc Base() {
    $BaseCurves=`ls -sl`;
};

global proc Top() {
    $TopCurves=`ls -sl`;
};

global proc test() {
    string $TopCurves[0];
};

希望这有帮助!