数组

数组的一些基础用法

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

 

posted @ 2014-10-10 18:21  amixc  阅读(316)  评论(0编辑  收藏  举报