将数组传递到全局过程
因此,我需要将数组传递到全局过程中,但像往常一样,我必须重新定义它。我知道这有点菜鸟问题,但是数组可以作为过程传递吗?如果没有,是否可以将其设为全局并插入到过程中。
$selectedFace = `ls -selection` ;
global proc crTestScripts($selectedFace) {
print ("OMG aren't lists of things awesome?!" + $selectedFace) ;
}
或者
$selectedFace = `ls -selection` ;
global array? $selectedFace ;
global proc crTestScripts() {
global array? $selectedFace ;
print ("OMG aren't lists of things awesome?!" + $selectedFace) ;
}
我传入此字符串,但仍然收到此错误:
错误:调用 applyCurrentType 时参数数量错误
以下是代码示例:
string $selectedFace[] = `ls -sl` ;
global proc applyCurrentType (string $selectedFace[]) {
print("Apply Current Type button clicked\n") ;
global int $applyCurrentType ;
$applyCurrentType = 1 ;
select -cl ;
select $selectedFace ;
crTestScripts ;
}
So I need to pass an array into a global procedure
, but as usual I have to redefine it. I know this is a bit of a noobie question, but can array be passed into as procedure? If not, could it be made global and inserted into a procedure.
$selectedFace = `ls -selection` ;
global proc crTestScripts($selectedFace) {
print ("OMG aren't lists of things awesome?!" + $selectedFace) ;
}
or
$selectedFace = `ls -selection` ;
global array? $selectedFace ;
global proc crTestScripts() {
global array? $selectedFace ;
print ("OMG aren't lists of things awesome?!" + $selectedFace) ;
}
I'm passing in this string and I still get this error:
Error: Wrong number of arguments on call to applyCurrentType
Here is a sample of the code:
string $selectedFace[] = `ls -sl` ;
global proc applyCurrentType (string $selectedFace[]) {
print("Apply Current Type button clicked\n") ;
global int $applyCurrentType ;
$applyCurrentType = 1 ;
select -cl ;
select $selectedFace ;
crTestScripts ;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在采用数组的自动装备脚本中使用了 proc createControllers(string $name[], int $position) 。在使用 mel 时,我不会使用术语“全局”,因为 Maya 很挑剔,并且每当我更改脚本时都只使用 rehash 函数;
为我工作。在 proc createControllers 中,我的 $name 数组等于我的 $rootNode 数组。
希望这有帮助,祝你好运!
I used
proc createControllers(string $name[], int $position)
in an auto rig script which is taking an array. I stay away from using the terms global when using mel since maya is picky and just use the rehash function whenever I make changes to my script;Worked for me. In the
proc createControllers
my$name
array is equal to my$rootNode
array.Hope this Helps, good luck!
我之前的回答是错误的。
因此,要将数组传递到过程中,您需要将其重新定义为全局变量,
string $selectedFace[];
将变为全局字符串$selectedFace[];
内部程序。例如:
crTestScripts();
// 结果:body_skinPrx_finalSkin.f[103]
filterExpand 有两个好处,它可以展平数组
ls -fl
,并且可以使用多个过滤器-sm 34 -sm 31
或者,我认为最好的方法...(我不喜欢全局变量)
只需对圆括号中的参数使用变量声明的正常语法即可:
参数:
使用先前的列表结果
$selectedFace
:hide_items($selectedFace);哎呀
...我忘记了 Maya 无法隐藏面孔 xD
my previous answer was wrong.
so to pass array into proc u need redefine it as global variable,
string $selectedFace[];
will becomeglobal string $selectedFace[];
inside procedure. e.g.:
crTestScripts();
// result: body_skinPrx_finalSkin.f[103]
filterExpand gives two benefits, it flattens array
ls -fl
, and u can use multiple filters-sm 34 -sm 31
or, i think best way... (i don't like global vars)
simply use normal syntax of variable declaration for args in round brackets:
*args:
using previous list result
$selectedFace
:hide_items($selectedFace);
oops... i forgot maya can't hide faces xD