数组

数组的一些基础用法

mybox=$Box* as array --收集数组元素
deleteItem mybox 1 --根据下标删除数组中的元素
sel=selection as array --将选择的物体作为数组赋值给sel

数组排序

--方法1
allBoxes
=selection as array --收集元素 objNames=for i in allBoxes collect i.name --收集物体的名字 sort objNames --排序 sortedObj=for i in objNames collect(getNodeByName i) print sortedObj ----------------------------------------------------------------------- --方法2
objs
= for i in $Box* collect i.name -- 收集获取到的物体名字 sort objs -- 排序 objs = for i in objs collect (getNodeByName i) print objs --在侦听器中打印结果 ----------------------------------------------------------------------- --方法3
objs
= for i in $Box* collect i.name -- 使用BitArray来定义索引 index = #{1,2,3,4,5} -- 通过索引重新定义 objs = for i in index collect (objs[i]) print objs -- 在侦听器中打印结果 ----------------------------------------------------------------------- objs = for i in $Box* collect i.name sort objs objs=for i in objs collect(getNodeByName i) index=#{1,2,3,4,5} objs=for i in index collect(objs[i]) select objs

 

转载于:https://www.cnblogs.com/amixc/p/4016950.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值