--随机树角度 oArray = $selection as array clearSelection() for i in oArray do ( --随机角度 angleValue = (random 5 30) *3 --format "角度:% /n" angleValue rotate i (angleaxis (random 0 90) [0,0,1]) ) --合并树递归方法 function attachTree oArray = ( if oArray.count < 2 then ( return "选择合并数量必须大于等于2" ) step = 2 if oArray.count>step then ( oArray2 = getCurrentSelection() for i =1 to oArray.count by step do ( j = i k = i+step l = i while (l+1)<k do ( --format "TTT:% , % /n" l oArray.count if l>=oArray.count then exit oArray[j].attach oArray[l+1] oArray[j] format "第一组合并进度:% , % ,%/n" l k oArray.count l+=1 ) append oArray2 oArray[j] ) --print oArray2.count --print oArray2 attachTree oArray2 ) else ( --print oArray oArrayCount = oArray.count for i = 2 to oArrayCount do ( format "第二组合并进度:% ,%/n" i oArray.count oArray[1].attach oArray[i] oArray[1] ) ) select oArray[1] ) --合并树 attachTree oArray --随机树高度 max modify mode modPanel.setCurrentObject $ subOjbectlevel = 1 --当前选择的点总数 faceCount = polyop.getNumVerts $ format "顶点总数:% /n" faceCount for i = 0 to (faceCount-8) by 8 do ( --随机高度值 heightValue = (random -.5 .5)*3 format "高度值:% ,i 值:%/n" heightValue i vertArray = #{i+3,i+4,i+7,i+8} $.EditablePoly.SetSelection #Vertex vertArray move $.selectedverts [0,heightValue,0] ) modPanel.setCurrentObject $.baseObject 使用方法:选择所要合并的树对象,执行脚本 说明: 主要修改了合并树的方法 第一次在脚本中使用了函数和递归方法