【问题标题】:How to get all but last item in a MEL array?如何获取 MEL 数组中除最后一项之外的所有内容?
【发布时间】:2016-03-26 18:10:38
【问题描述】:

我想获得用户选择并将除最后一个对象之外的所有对象分配给一个数组变量,并将最后一个选定对象分配给另一个变量。

我该怎么做?

谢谢

【问题讨论】:

  • 到目前为止你有什么代码?
  • 我有一个工作代码,但它不是那么好。所以我正在改变像这样的第一行 string $sel[] = ls -sl; int $lastSel = 大小 ($sel); stringArrayRemoveAtIndex(($lastSel - 1), $sel);字符串 $targetSel[] = $sel;字符串 $base = $lastSel;字符串 $baseCopy[] = duplicate $base;
  • @Andy string $wholeSel[] = ls -sl; string $targetList[] = ls -sl -hd (size($iniSel1) - 1); string $base = $wholeSel[size($wholeSel) - 1]; 我像这样重做它并且它有效。但也许有更优雅的方式?

标签: arrays string selection maya mel


【解决方案1】:
$first = `ls -sl -head 1`;
$last = `ls -sl -tail 1`;
string $all_except_last[] = stringArrayRemove(`ls -sl -tail 1`, `ls -sl -fl`);
string $all_except_first[] = stringArrayRemove(`ls -sl -head 1`, `ls -sl -fl`);
//don't forget to use -fl (flat list) flag

【讨论】:

  • 谢谢。 “平面列表”标志有什么作用?我在参考文献中没有找到。我们也可以在这里使用 $list[0] 作为第一项吗?
  • 当然你可以使用$list[0]。组件的更多平面列表(pSphere1.f[255:258] vs pSphere1.f[255] pSphere1.f[256] pSphere1.f[257] pSphere1.f[258])。展平返回的对象列表,以便单独标识每个组件。
猜你喜欢
  • 2011-03-13
  • 1970-01-01
  • 1970-01-01
  • 2011-03-31
  • 2020-01-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-07-10
相关资源
最近更新 更多