zoukankan      html  css  js  c++  java
  • 2011.4.23 周六建模工具完成。(以后修改再说)(mode(建模工具)1.0)

     
    --- rollout
    global gt_Scatter_tool
    /*
     ----这里我判断不用了
    global localHit=[0,0,0], localNormal=[0,0,0], worldHit=[0,0,0], worldNormal=[0,0,0] ----原来这里的东西早就不用了
    global helperOBJ = undefined
    */
    global ScatOBJ = undefined  ---着一点值得我学习。是什么呢, 全局还要给初始值。 在我之前开发的脚本系类中最后的bug 都是因为这了、
    global timeS1=timestamp(),  timeS2=timestamp() --主板行走时间
    global SCT_TargetOBJ =#() , TobjST

      
    struct TargetOBJ  (obj, randomValue=1, rotateV=0, sizeV=100, rotateX=0, rotateY=0, rotateZ=0, MoveV=0, OriginalScale=[1,1,1])
    TobjST = TargetOBJ() ---定义结构 这里是为了随时的存入值,可以随时的取出值。


    fn OBJsizeFN  obj = (   --如果输入的物体没有被删就求出最大减最小/2 之间的距离。
     if (isdeleted obj) == true do return 0
     ma= obj.max
     mi= obj.min
     
     return ((distance ma mi)/2.) -----这个函数在下面的应用主要说明笔刷的大小。
    )

    fn helperFN =
    (
    -- map=mapScreenToCP mouse.pos (getViewSize())
    -- point pos:map
                               ---因为这里调用对话况的控件 古全局定义这个数。
     if ScatOBJ == undefined or gt_Scatter_tool.start_btn.state == OFF  do return false ----但我第一次拾取物体时。ScatOBJ 就定义了。
      ---在这个函数中以上两个条件有一个对就返回。 这里开始进行肯定是返回的
     mouseray = mapScreenToWorldRay mouse.pos --这里应该是鼠标屏幕对应的射线
     sectray = intersectRAY ScatOBJ mouseray   -------------------------------------鼠标工具与拾取物体的焦点。
     
      ---求出一个焦点,是这样的。节点是shape 返回undefined 和曲面没有焦点也是没有的。
     if sectray == undefined do return false --没有焦点结束函数              -------------由于时间是不断检查的,所以一旦有就会往下进行。

    -- TobjST.randomValue = random 1  SCT_TargetOBJ.count

     if TobjST.obj == undefined  or  (isdeleted TobjST.obj) == true  then ----------------我现在觉得应该会进入这个事件中去。 -----第一次肯定是要进去,因为我们没有指定过,
     --如果结构中的obj没有指定,或者是被删了进行下面的操作,并且是带回车的。
     (
      undo on (
                                              ---其实下面是定义了一个空组。就是开始什么都没有,慢慢的在+ 中加入。
       TobjST.randomValue = random 1  SCT_TargetOBJ.count --结构中的数量等于1 到到列队中的个数。
       
       ---关于random 的用法1 0 是有事时1 有时时零。在这个中因为都是。integer所以返回的必定是整数、
       
     
       TobjST.obj = instance SCT_TargetOBJ[TobjST.randomValue] --定义了obj为赋值关联类表中的某一个。
       
       ------这里定义了结构中的这个节点
       
       
       TobjST.sizeV = random gt_Scatter_tool.MinScale_spi.value  gt_Scatter_tool.MaxScale_spi.value
       --sizeV 默认是100 这里面又要从新定义。这里是缩放函数 在这里重新的读取一下界面中的数。

       TobjST.rotateX = random gt_Scatter_tool.MinRotateX_spi.value  gt_Scatter_tool.MaxRotateX_spi.value
       TobjST.rotateY = random gt_Scatter_tool.MinRotateY_spi.value  gt_Scatter_tool.MaxRotateY_spi.value
       TobjST.rotateZ = random gt_Scatter_tool.MinRotateZ_spi.value  gt_Scatter_tool.MaxRotateZ_spi.value
                ----上面重新定义了旋转的随机函数。   
       
       TobjST.MoveV = random gt_Scatter_tool.MinMove_spi.value  gt_Scatter_tool.MaxMove_spi.value
                ---定义了高低的随机函数
       
       ---这里面定义了画笔的大小,用的是函数是制定物体的半径
       thePainterInterface.maxSize= OBJsizeFN  TobjST.obj

      --- thePainterInterface 是个绘画函数
       
       TobjST.obj.dir = sectray.dir---下面的每一个几何体和鼠标 对应 的射线
       --说的是什么轴向向上。
       
       --物体的射线方向
       TobjST.obj.name = "scatter_Helper" --- 这里 是明明几何体的名字。
       ---应为随着时间的绘画这里是不断的关联复制。
       
       
       in coordsys local TobjST.obj.rotation = (EulerAngles  TobjST.rotateX  TobjST.rotateY (TobjST.rotateV + TobjST.rotateZ) )
       ---在自身的坐标轴下,结构中物体的旋转, 在z轴上加入了一个旋转v 这个很重要。
       ----上面是说明在进行自身的旋转, 在z轴上加入了一些变化 明白了。加入了rotateV也就是说。打上自动旋转后。同时还可以按下shift 进行旋转处理。
       
       
       TobjST.OriginalScale = TobjST.obj.scale --已经有了定义在定义变化。
       --重新定义结构体中的 OriginalScale 的值,
       
       
       TobjST.obj.scale = (TobjST.OriginalScale * (TobjST.sizeV/100.)) ---实现了随机的缩放。
        ---算法。上面的上面是吧obj的上次缩放给 Originalscale  相当于本身 在乘以一个随机的%比。

       TobjST.obj.pos = sectray.pos ---鼠标与几何体的表面
        ---这个是最重要的一部了,就是把物体画到表面的东西
        
       in coordsys local TobjST.obj.pos = [0,0, TobjST.MoveV] ---在这里明白操作 就是不明白解释。
        
       ----明白了终于明白了,这里面说的是,物体的当给了变化值,在自身的方向,z轴在移动一次。相当于先给 了点,在在点上是为原点在移动

      )
     )
     else (
      TobjST.obj.pos = sectray.pos
      in coordsys local TobjST.obj.pos = [0,0, TobjST.MoveV]

      TobjST.obj.dir = sectray.dir
      in coordsys local TobjST.obj.rotation = (EulerAngles  TobjST.rotateX  TobjST.rotateY (TobjST.rotateV + TobjST.rotateZ) )
      TobjST.obj.scale = (TobjST.OriginalScale * (TobjST.sizeV/100.))
     )
     
     setSysCur #uscale

    )


    fn OBJrotateFN = (
     TobjST.rotateV += gt_Scatter_tool.add_del_.value
    )
    --------------------------对于绑定的操作我想加入-10 --------------
    fn OBJrotateFN__ = (
     TobjST.rotateV -= gt_Scatter_tool.add_del_.value --------在此验证了+ —— 是不加空格的
    )

    fn  MouseOverObject = ( ---------------------------------------这里应该是鼠标移动事件。
     ga =$geometry as array ---把所有的做pick

    -- ga = for i in ga where i.name != "scatter_Helper"  collect i

     delga = finditem ga $scatter_Helper ---在几何体中查找这个物体,
     if  delga != 0 do  deleteitem ga delga  ---如果查找 到了 $scatter_Helper 这个节点  就从数组中删除它。
     
     mouseray = mapScreenToWorldRay mouse.pos ---又做一条射线。
     coOBJ = #();   coRay=#() ---两个备用数组。
     for i in ga do  (
      sectray = intersectRAY i mouseray  --鼠标射线和所有的物体间的交汇处 ------------因为这些函数在时间的节点下实时进行。
      if sectray != undefind  do ( --- 这里面的交汇只能是个几何体 没有交上, 是undefind 
       append  coOBJ   i ---物体加入到
       append  coRay  sectray ----把没有找到物体的射线加入到这个里面。
      )
     )
     if coRay.count == 0 do return false  ---如果鼠标射线和所有物体没有交点 那么这个数组就是0 返回  不在往下进行。鼠标射线不可能所有的
      --物体没有交点,所以用到这里一般有效 我们知道这里是按下ctrl 找被刷物体时的事件。

     vv= (inverse (viewport.getTM())).pos  ---求出相反的矩阵 的pos
     cTemp= distance  vv coRay[1].pos;   cTempI = 1
     
     for i in 1 to coRay.count do (
      if cTemp > (distance  vv coRay[i].pos) do (
       cTemp= (distance  vv coRay[i].pos)
       cTempI = i
      )
     )

     format "%   %\n" coOBJ[cTempI].name   cTemp ----- 这里对于对于距离输出,还是很不好明白。
     return coOBJ[cTempI]
    )


    fn newOBJcheckFN =(                             -----------------------这个函数在中标中进行对于人的操作速度来说几乎是事实进行的。
     local mState= mouse.buttonStates               ----鼠标按下的状态。
     local mouseState=mState as array --转换成数组。花括号 转小括号。


     if keyboard.shiftPressed == ON and  keyboard.controlPressed == OFF  and  gt_Scatter_tool.start_btn.state  == ON   do (
      TobjST.rotateV= OBJrotateFN() ---旋转递加
      ---这个功能我刚刚用到
     )
     
     if keyboard.shiftPressed == ON and  keyboard.controlPressed == on  and  gt_Scatter_tool.start_btn.state  == ON   do (
      TobjST.rotateV= OBJrotateFN__() ---旋转递加
      ---这个功能我刚刚用到
     )

     
     --- keyboard ctrl  滚瓢捞 喘府搁 促弗坷宏璃飘 急琶
     if keyboard.controlPressed == ON  and  keyboard.shiftPressed == OFF   and  gt_Scatter_tool.start_btn.state  == ON   do (
      MOO = MouseOverObject()
    --  print MOO
      if MOO == false do return false  -----这个事件主要是说明给要刷的物体换东西。
      gt_Scatter_tool.obj_btn.picked  MOO
     )
    )

    fn startStroke = (
     print "start"
    )

    fn paintStroke = (

    -- thePainterInterface.getHitPointData &localHit &localNormal &worldHit &worldNormal 0.5 0.5 0
    -- format "%  %  %  %\n" localHit localNormal  worldHit  worldNormal

     if TobjST.obj == undefined do return false
     timeS2=timestamp() ---重新定义取新的时间。
     timeT =  timeS2 - timeS1  ----------------------找出时间差  如果大于100 才创建东西。小于则不见。
     if timeT > gt_Scatter_tool.bugu_bul.value do  (
    --  box pos:worldHit dir:worldNormal   --- 其牢飘牢磐其捞胶甫 荤侩且版快俊绰 捞巴阑 荤侩... face 俊 畴富蔼阑 舅酒晨
    --  helperOBJPaint =  TobjST.obj
    --  helperOBJPaint.pos = worldHit
    --  helperOBJPaint.dir = worldNormal
      TobjST.obj.name = uniqueName "scatter_Helper" ---唯一的命名 也是第一个命名 在删除时则总是删除这个。
      timeS1=timestamp()  
      TobjST.obj = undefined
     )

     
    )


    fn cancelStroke = print "Handle cancel stroke here"
    fn endStroke = (
     thePainterInterface.updateMeshes on
    -- print "Update"
    )


    fn initFN_2 = (
    -- nodeList = ScatOBJ   --- 盔贰绰 捞巴!!
     nodeList = undefined
     thePainterInterface.initializeNodes 0 nodeList
    )

    fn initFN = (
     thePainterInterface.endPaintSession()
    -- if Dig_tool.obj_btn.object == undefined do return false
    --- if (Superclassof Dig_tool.obj_btn.object) != GeometryClass  do return false

    ---   其牢磐 牢磐其捞胶甫 荤侩窍登 坷宏璃飘甫 固沥狼窍骨肺辑 加档甫 俺急矫糯
    -- nodeList = ScatOBJ   --- 盔贰绰 捞巴!!
     nodeList = undefined
     
     
     thePainterInterface.initializeNodes 0 nodeList
     try( thePainterInterface.maxSize= OBJsizeFN  TobjST.obj  )catch() --这里的笔刷算法相当于物体的半径。最大减最小在除2 。
     thePainterInterface.ScriptFunctions startStroke paintStroke endStroke cancelStroke systemEnd
     thePainterInterface.offMeshHitType = 2
     
        thePainterInterface.updateOnMouseUp =false
     thePainterInterface.drawTrace =On
     thePainterInterface.drawNormal = off
     thePainterInterface.drawRing = off
      --thePainterInterface.maxSize=2000
     thePainterInterface.treeDepth = 2
     thePainterInterface.pressureEnable = OFF
     thePainterInterface.pressureAffects = 1
     --thePainterInterface.dragStrLimitMin=100
     --thePainterInterface.dragStrLimitMax=100

     
     thePainterInterface.startPaintSession()----画笔开始
     setSysCur #uscale --鼠标状态
    )

    try(destroyDialog gt_Scatter_tool)catch()
    rollout gt_Scatter_tool "(盖天)繁殖:绑定:.." 210 height:300
    (      
      fn  load_icon  = (
      a=openbitmap  ((GetDir #ui)+ "\\Icons\\"  + "Classic_16i.bmp")-- 位图的打开
      return a
      )
         ----------我在这里还要加入一个对于数据的控制 -------------------------
      --学习理论基础把控件名称变量成一个组,把控件名称变量的默认值成一个组,这样就好了 利用 打开和关闭进行数据的存储,这个效果很是好。


     pickbutton obj_btn "拾取表面物体" pos:[44,8] 88 height:21

     button Tobj_pick "+" pos:[4,38] 20 height:50 toolTip:"add selection Scatter Objects"
     button Tobj_del "-" pos:[4,93] 20 height:15 toolTip:"Delete Scatter Object"
     listbox SCT_lit "" pos:[33,39] 160 height:5 items:SCT_TargetOBJ
     spinner MinScale_spi "" pos:[60,128] 55 height:16 range:[0,500,100]
     spinner MaxScale_spi "" pos:[130,128] 55 height:16 range:[0,500,100]

     spinner MinRotateX_spi "" pos:[60,158] 55 height:16 range:[-500,500,0]
     spinner MaxRotateX_spi "" pos:[130,158] 55 height:16 range:[-500,500,0]
     spinner MinRotateY_spi "" pos:[60,178] 55 height:16 range:[-500,500,0]
     spinner MaxRotateY_spi "" pos:[130,178] 55 height:16 range:[-500,500,0]
     spinner MinRotateZ_spi "" pos:[60,198] 55 height:16 range:[-500,500,0]
     spinner MaxRotateZ_spi "" pos:[130,198] 55 height:16 range:[-500,500,0]

     spinner MinMove_spi "" pos:[60,228] 55 height:16 range:[-10000,10000,0]
     spinner MaxMove_spi "" pos:[130,228] 55 height:16 range:[-10000,10000,0]
     
     button ScaleIcon_btn "" pos:[20,125] 20 height:20 images:#(load_icon() , undefined, 78, 25, 25, 1, 1)   
     --基本明白了 路径引用图片 通道图 有多少子图 可用时 做的输入 输出 不可用是桌的输入输出。
     button RotateIcon_btn "" pos:[20,175] 20 height:20 images:#(load_icon(), undefined, 78, 23, 23, 1, 1)   
     button MoveIcon_btn "" pos:[20,226] 20 height:20 images:#(load_icon(), undefined, 78, 21, 21, 1, 1)
     GroupBox ScaleGroup "" pos:[10,113] 185 height:38
     GroupBox RotateGroup "" pos:[10,144] 185 height:77
     GroupBox MoveGroup "" pos:[10,213] 185 height:40
       
     spinner add_del_ "+_-" pos:[20,260] 70 height:16 range:[-360,360,10] type:#integer
     spinner bugu_bul "paint_fu" pos:[40,280] 70 height:16 range:[0,1200,100] type:#integer

     checkbutton start_btn "开始 !!" pos:[120,261] 80 height:25

     timer clock "testClock" interval:50 --有钟表这个东西一切都来的好。

     -------------------繁重事件的处理-----------------------------------------
      global oop_sel_lingshi_edt_text =undefined
     
      on pick_obj_btn37  picked obj do

    (
     if obj != undefined do
    (
    pick_obj_btn37.text = obj.name
    )
    )--end on

        on  copy_one_to_big_btn38 pressed do with undo on
     ( 
      if oop_sel_lingshi_edt_text!= undefined then
      (
      if oop_sel_lingshi_edt_text.count >0 then
      (
                if  pick_obj_btn37.text!=  "拾取繁重物体" then
       (    
       
       for i in 1 to oop_sel_lingshi_edt_text.count do
       (
        doit_prog.value = 100.*i/oop_sel_lingshi_edt_text.count
        ui_pick_obj =   execute( "$" + pick_obj_btn37.text)
        if ui_pick_obj ==undefined then
        (
         messageBox "节点丢失。"title:"盖天编写"
         return false
        )
        
        pp_cy = instance ui_pick_obj
        
        pp_cy.name = uniquename  ("instance_"+pick_obj_btn37.text)
        
        pp_cy.transform =oop_sel_lingshi_edt_text[i].transform
        
        
       )
          )
       
       
      )
      doit_prog.value = 0  
     )
     )
     
     
        local ctrlSp=#(MinScale_spi,MaxScale_spi,MinRotateX_spi,MaxRotateX_spi, MinRotateY_spi, MaxRotateY_spi,MinRotateZ_spi, MaxRotateZ_spi ,MinMove_spi,MaxMove_spi\
        ,add_del_,bugu_bul),
        spIni =#(100,100,0,0,0,0,0,0,0,0,10,100   )
      -----创建点到点的处理
      global oop_sel_lingshi_lenght=undefined

     on clock tick do ----开始时钟就走。
     (
      helperFN()
      newOBJcheckFN()

      if thePainterInterface.inPaintMode() == OFF do start_btn.checked=OFF
     )

     on MinMove_spi changed val do (
      try (delete $scatter_Helper )catch()  ----这里为什么盈动是要删除的,而缩放选择就是不用。
      TobjST.obj = undefined          -----我们一直是利用结构。我想结构其实就是一个全局变量,
     )
     on MaxMove_spi changed val do (
      try (delete $scatter_Helper )catch()
      TobjST.obj = undefined
     )

     on Tobj_del pressed do (
      try(
       delval = gt_Scatter_tool.SCT_lit.selection
       deleteitem  SCT_TargetOBJ  delval
      )catch()

      TobjName=for i in SCT_TargetOBJ collect i.name
      gt_Scatter_tool.SCT_lit.items = TobjName
     )

     on Tobj_pick  pressed do (
      objs= selection as array
      join  SCT_TargetOBJ  objs
      
      TobjName=for i in SCT_TargetOBJ collect i.name
      
      SCT_lit.items = TobjName ---这里是典型的加入节点,收集名字。
     )


     on obj_btn picked obj do (
      ScatOBJ = obj
      obj_btn.text = obj.name

      initFN_2()
     )


     on  start_btn  changed state do   (
      if gt_Scatter_tool.SCT_lit.items.count == 0 do return false ----列队数列0 什么不做
     --Box lengthsegs:1 widthsegs:1 heightsegs:1 length:43.4603 77.2628 height:25.9733 mapcoords:on
      if state == ON do initFN() ---这个是最开始事件,下来就是时间进行的一系列的变化。
      
      ---------------------------好像是错了在没有按下之前就已经是种再走了。
      
      if state == OFF do  (
       thePainterInterface.endPaintSession() ---关闭画笔 删除根部节点。
       try (delete $scatter_Helper )catch()
      )
     )
     
     on gt_Scatter_tool open  do for i=1 to ctrlSp.count do (v=getIniSetting "$plugcfg/gt_fan_zhi_bangding_.ini" "disturbSel" (ctrlSp[i] as string);ctrlSp[i].value=if v=="" then spIni[i] else v as float )
     on gt_Scatter_tool close do for i=1 to ctrlSp.count do  setINISetting   "$plugcfg/gt_fan_zhi_bangding_.ini" "disturbSel" (ctrlSp[i] as string) (ctrlSp[i].value as string)
     
     
    )


    ------自动模型 
     function  gray_material_balk_wire =
       (
        oo_mat = selection as array
         for i in oo_mat do
         ( 
          --其实应该判断他有没有贴图 如果有就不好了 这里呢我就用名字代替下
          if   classof meditMaterials[1]== Standardmaterial and  meditMaterials[1].name == "Standardmaterial"then
          (
            i.material=meditMaterials[1]
           i.wirecolor = black
          )else
          (
            meditMaterials[1]= Standardmaterial()
           meditMaterials[1].name ="Standardmaterial"
            i.material=meditMaterials[1]
           i.wirecolor = black
          
          )
          --这个不好没戏合并时都是很费事 所哟我用材质球 进行 
         
          )
       )--end fn
       ----自动poly
        function four_face =
       (
      
       addModifier   $  (Turn_to_Poly())

       $.modifiers[1].limitPolySize=true
       $.modifiers[1].maxPolySize=4
     macros.run "Modifier Stack" "Convert_to_Poly"
       )
       ------box
        function gt_box_box =
      (
       oop= selection as array 
      
       for i in oop  do
       (
          i.boxmode =not  i.boxmode
         
       )  
      )
      ----xform
      fn gt_Xform_tt =
      (
       ---下面的过程需要算下。
       --1.先找到物体的transform
       --2.在把物体归零,加入修改器
       --3.在转动他的 Gizmo
       --4.把它进行塌陷
       
       --脚本中指处理了物体的旋转 还要处理物体的缩放。
       for i in selection do  
       (
        ---2011.4.18 我想加入对线 和体的 操作。对于别的不进行操作。
        if  (superClassOf i ==GeometryClass and  ClassOf i != Targetobject)  or   superClassOf i ==shape then
        (
         if  InstanceMgr.GetInstances i &instances != 1 then
         (
          if superClassOf i ==shape then macros.run "Modifier Stack" "Convert_to_Spline"
          
          if superClassOf i ==GeometryClass then convertTo i Editable_Poly
         )
        
        oo = [i.rotation.x_rotation ,i.rotation.y_rotation ,i.rotation.z_rotation ]
         --我在制作时改了思路 这下就好了
         pos_pos = i.pos

        i.rotation.x_rotation =0
        i.rotation.y_rotation=0
        i.rotation.z_rotation =0
        
        ---处理缩放
         secle_a = i.scale
                   
        i.scale=[1,1,1]

        addModifier   i (XForm())

                  
        i.modifiers[1].Gizmo[2].controller[1].value  =oo[1]
        i.modifiers[1].Gizmo[2].controller[2].value  =oo[2]
        i.modifiers[1].Gizmo[2].controller[3].value  =oo[3]
                    
        i.modifiers[1].Gizmo[3].controller.value =secle_a
        
        

              convertTo i Editable_Poly
             )   
       )
       ---上面就是脚本解决的过程 这下我有知道Xform 深的理解
       
       
      )

     try(cui.UnRegisterDialogBar gt_mode_big)catch()-----这个是法则。
    try (DestroyDialog gt_mode_big )catch()
    rollout gt_mode_big "模型常用" 160 height:132
    (
     button Project_But "工程目录" pos:[29,4] 92 height:18
     button an_mode_btn "自动模型" pos:[9,26] 70 height:18
     button global_but "全局冻结" pos:[82,26] 70 height:18
     button automation_btn "自动poly" pos:[9,48] 70 height:18
     button box_btn "box盒" pos:[82,48] 70 height:18
     button form_btn "归Xform" pos:[9,69] 70 height:18
     button scatt_btn "散布" pos:[82,69] 70 height:18
     
     on Project_But pressed do
     (
      SubPathNameList = #(#animations,#archives,#downloads,#export,#expression,#image,#import,#matlib,#maxstart,#Photometric,#preview,#proxies,#renderassets,#renderPresets,#renderoutput,#scene,#sound,#vpost)
    for i in SubPathNameList  do
     SetDir i ( "."+"\\"+i as string)
    pathConfig.doProjectSetupSteps()
      
      
     )---end on
     on an_mode_btn pressed do
     (
      gray_material_balk_wire()
     )---end on
     on global_but pressed do
     (
      try (
       function all_freeze_tan =
       (
        global all_obj_freeze


       oop  = selection as array
        if oop.count !=0 then
        (
        all_obj_freeze= oop
        )

          for i in all_obj_freeze do
       (
              i. isFrozen =not  i. isFrozen
          i.showFrozenInGray =false
        -- i.showFrozenInGray = not i.showFrozenInGray
       )  
       )
       all_freeze_tan()
              )catch( messagebox ("全局变量已换。"))
      
     )-----end on
     on automation_btn pressed do
     (
       try (four_face ()) catch ()
     )---end on
     on box_btn pressed do
     (
       try ( gt_box_box()) catch ()
     )---end on
     on form_btn pressed do
     (
       try ( gt_Xform_tt()) catch ()
     )---end on
     on scatt_btn pressed do
     (

    createdialog gt_Scatter_tool style:#(#style_titlebar, #style_border, #style_sysmenu,#style_minimizebox )

     )---end on
     
     
    )
    ----***************************************************************************
    ---------*****************变换轴心点**************************************************************-----------
     try(cui.UnRegisterDialogBar transPivot)catch()-----这个是法则。
    try (DestroyDialog transPivot )catch()
    global gt_yc_Ail
     fn g_filter o = superclassof o == Geometryclass
     fn find_intersection z_node node_to_z =
     (
      try(
      --同样的条件 数字及计算要比字符串快 所以能用数字 不用字符串。
      ---改写成自动的循环处理的, 我考虑的因为只有6 个 所有用循环擦看。
      local oop
             local  compare_array =#()  
      for i in 1 to 6 do
      (
     oop=case of

       (

       (i==1): [0,0,-1]

       (i ==2): [0,0,1]
        
       (i ==3):[-1,0,0]
        
       (i==4):[1,0,0]
        
       (i ==5):[0,-1,0]
        
       (i ==6):[0,1,0]

       --default: reference $foo
       )
      -- print oop

      local testRay = ray node_to_z.pos  oop
      local nodeMaxZ
      
       case oop  of
       (  ------Z 轴
        ([0,0,-1]) :(nodeMaxZ = z_node.max.z
         testRay.pos.z = nodeMaxZ + 0.0001 * abs nodeMaxZ
         
         )
        ([0,0,1]) :(nodeMaxZ = z_node.min.z
         testRay.pos.z = nodeMaxZ - 0.0001 * abs nodeMaxZ  
        )
        -------X轴 
        ([-1,0,0]) : (nodeMaxZ = z_node.max.x
         testRay.pos.x = nodeMaxZ + 0.0001 * abs nodeMaxZ   
        )
        ([1,0,0]) : (nodeMaxZ = z_node.min.x
        testRay.pos.x = nodeMaxZ - 0.0001 * abs nodeMaxZ   
        )
       ------- Y轴
              ([0,-1,0]) : (nodeMaxZ = z_node.max.y
        testRay.pos.y = nodeMaxZ + 0.0001 * abs nodeMaxZ   
        )
        ([0,1,0]) : (nodeMaxZ = z_node.min.y
        testRay.pos.y = nodeMaxZ - 0.0001 * abs nodeMaxZ   
        ) 
       )
       
           
      --)
      --testRay.pos.z = nodeMaxZ + 0.0001 * abs nodeMaxZ
        if  intersectRay z_node testRay !=undefined then
        (
         ---因为我先做了x轴的负方向 其实两个方向是同事存在了 所有 好要进行比较了
        --return
           append  compare_array  (intersectRay z_node testRay)
        
       --  exit
        
        )
        
           
       
      )/*
       for i in compare_array do
       (
       distance_d =   distance  $selection[1].pos  i.pos
      --print compare_array[1].pos
        distance_c=0
        if distance_d>= distance_c then
        (
          distance_c =distance_d
        )
       
       )*/
      ---其实就有两个我比较下好; 用列举法
       distance_d =   distance  $selection[1].pos  compare_array[1].pos
      try ( distance_c =   distance  $selection[1].pos  compare_array[2].pos )
      catch ( distance_c =distance_d+20)
        if amin distance_d  distance_c == distance_d then
        (
         return compare_array[1]
        )else
        (
         return compare_array[2]
        )
       ) catch ()
      
     )
    rollout transPivot "变换轴心点" 160 height:344
    (
     
     local alignToObj=0,
        usePivot
     pickbutton alObj "alignTo:(onesel/...)" pos:[4,4] 104 height:15
     button alSel "清除" pos:[114,4] 35 height:15
     button al5 "X_max" pos:[4,30] 70 height:18
     button al6 "X_min" pos:[81,29] 70 height:18
     button al1 "Y_max" pos:[4,52] 70 height:18
     button al3 "Y_min" pos:[81,51] 70 height:18
     button al2 "Z_max" pos:[4,74] 70 height:18
     button al4 "Z_min" pos:[81,73] 70 height:18
     button alc "中心" pos:[4,96] 70 height:18
     button alR "随机" pos:[81,95] 70 height:18
     spinner mult "倍率" pos:[10,119] 55 height:16 range:[0,10,1]
     spinner multR "倍率随机" pos:[85,120] 70 height:16 range:[0,10,0]
     button pick_btn1 "自动对齐" pos:[40,142] 70 height:18 enabled:true
     
     ----------------------
     fn rotatePivotOnly obj rotation =
     (
      local rotValInv=rotation as quat
      animate off
      in coordsys local obj.rotation*=RotValInv
      obj.objectoffsetrot*=RotValInv
      obj.objectoffsetpos*=RotValInv
     )
     on alObj picked obj do (alignToObj= obj; alObj.text=("alignTo: "+obj.name); sel=getCurrentSelection(); for i=1 to sel.count do (resetPivot sel[i];  rotatePivotOnly sel[i] alignToObj.rotation;  sel[i].pivot=alignToObj.pivot) )
     on alSel pressed do (alignToObj=0; alObj.text="alignTo:(onesel/...)")
     on al1 pressed do ( sel=getCurrentSelection(); for i=1 to sel.count do (obj=if alignToObj==0 then sel[i] else alignToObj; sel[i].pivot.y=obj.max.y+(mult.value-1+random 0.0 multR.value)*(obj.max.y-obj.min.y) ) )
     on al2 pressed do ( sel=getCurrentSelection(); for i=1 to sel.count do (obj=if alignToObj==0 then sel[i] else alignToObj; sel[i].pivot.z=obj.max.z+(mult.value-1+random 0.0 multR.value)*(obj.max.z-obj.min.z) ) )
     on al3 pressed do ( sel=getCurrentSelection(); for i=1 to sel.count do (obj=if alignToObj==0 then sel[i] else alignToObj; sel[i].pivot.y=obj.min.y-(mult.value-1+random 0.0 multR.value)*(obj.max.y-obj.min.y) ) )
     on al4 pressed do ( sel=getCurrentSelection(); for i=1 to sel.count do (obj=if alignToObj==0 then sel[i] else alignToObj; sel[i].pivot.z=obj.min.z-(mult.value-1+random 0.0 multR.value)*(obj.max.z-obj.min.z) ) )
     on al5 pressed do ( sel=getCurrentSelection(); for i=1 to sel.count do (obj=if alignToObj==0 then sel[i] else alignToObj; sel[i].pivot.x=obj.max.x+(mult.value-1+random 0.0 multR.value)*(obj.max.x-obj.min.x) ) )
     on al6 pressed do ( sel=getCurrentSelection(); for i=1 to sel.count do (obj=if alignToObj==0 then sel[i] else alignToObj; sel[i].pivot.x=obj.min.x-(mult.value-1+random 0.0 multR.value)*(obj.max.x-obj.min.x) ) )
     on alc pressed do (
          sel=getCurrentSelection()
          for i=1 to sel.count do
          (
           obj=if alignToObj==0 then sel[i] else alignToObj
           sel[i].pivot.x=obj.min.x+0.5*(obj.max.x-obj.min.x); sel[i].pivot.y=obj.min.y+0.5*(obj.max.y-obj.min.y); sel[i].pivot.z=obj.min.z+0.5*(obj.max.z-obj.min.z) )
         )
     on alr pressed do (
          sel=getCurrentSelection()
          for i=1 to sel.count do
          (
           obj=if alignToObj==0 then sel[i] else alignToObj
           sel[i].pivot.x=random (obj.min.x-(mult.value-1+random 0.0 multR.value)*(obj.max.x-obj.min.x)) (obj.max.x+(mult.value-1+random 0.0 multR.value)*(obj.max.x-obj.min.x))
           sel[i].pivot.y=random (obj.min.y-(mult.value-1+random 0.0 multR.value)*(obj.max.y-obj.min.y)) (obj.max.y+(mult.value-1+random 0.0 multR.value)*(obj.max.y-obj.min.y))
           sel[i].pivot.z=random (obj.min.z-(mult.value-1+random 0.0 multR.value)*(obj.max.z-obj.min.z)) (obj.max.z+(mult.value-1+random 0.0 multR.value)*(obj.max.z-obj.min.z))
          )
         )
         
       on pick_btn1 pressed do
     (
      ---从上到下执行。先执行这里的这个。
      target_mesh = pickObject message:"Pick Target Surface:" filter:g_filter --- 这种拾取的方法更好。不用再显示;
      if isValidNode target_mesh then ---这个好用, 是如果节点没有被删除。
      (
       undo "MoveToSurface" on
       (
        for i in selection do
        (
         int_point = find_intersection target_mesh i
       -- print  int_point as string
         if int_point != undefined and  int_point != ok then
       (
       i.pos = int_point.pos
       -- print int_point.pos
      )
        )--end i loop
       )--end undo
      )--end if
     )--end pressed     
     on transPivot open do ( usePivot=getCoordCenter(); toolMode.pivotCenter() )
     on transPivot close do case usePivot of( #local:toolMode.pivotCenter(); #selection:toolMode.selectionCenter(); #system:toolMode.transformCenter() )
    )--end rollout

    --********************************************************************************


    ---看到别人的东西是根据选择体的线,选择相应的体中的线。
    --1.选择线判断两点距离。其实这我也就明白了容差在这里到底是什么意思。---、
    --2.把模型的所有点找到。做递归的两点距离判断。 在容差范围内的,看看是否能还原出线。如果不行就没事。如果行就加到数组中
    --3.进行选择。
    --4. 关与线的方式我想不出来什么 我觉得就是递增判断距离。--其实后来我用的不是那个。是用的循环线。
     
     --判断物体收集所以线
     --因为每条线都有两个点,判断线的距离。
     
     fn Equal_spline input_poly tolerance =   ---这个函数是查找相等的线,input_poly 是输入的模型信息,判断是poly tolerance 容差数子。
      --在一定范围内的线被选择。
     (
        local line_space =0 --初始化间距
        local endge_length_array =#() ---收集的线的长度数组。
      --只对于是poly 或者是mesh
      if  superclassof input_poly ==GeometryClass  then
      (
        if classof input_poly == Editable_Poly then  --polyop.getEdgeSelection --这个以后还有很到的改善的地方,主要应用于层级的poly mesh
        (
        ---求的总边数
                 oop_Eng =  polyop.getNumEdges  input_poly
                 
                ---先判断第一个边。找起长度。在进行循环比较
                  Edge_array = polyop.getEdgeSelection  input_poly  as array --转成数组好判断个数这个很好。
         if Edge_array.count == 1 then
         (
        
          verts_array = polyop.getEdgeVerts input_poly  Edge_array[1] ---返回边的顶点。--着是个数组
          ---还有这里肯定是两个点的数组。所以我在这里直接用索引就好了。
         
          ---判断距离
         
           date_dis_1 = polyop.getVert  input_poly  verts_array[1]
           date_dis_2 = polyop.getVert  input_poly  verts_array[2]
         
             line_space = distance  date_dis_1 date_dis_2
            -- line_space=line_space+tolerance
          
         )else  return false
                   
         ---这里面做循环判断间距。距离在一定范围内加入数组。
         for i in 1 to oop_Eng do ---对每个边进行循环,也就是说,要有很多的point 数组产生 这里要进行长度判断。
         (
          verts_array = polyop.getEdgeVerts input_poly i
         
           date_dis_3 = polyop.getVert  input_poly  verts_array[1]
           date_dis_4 = polyop.getVert  input_poly  verts_array[2]
         
           local_line_space =distance  date_dis_3 date_dis_4
          ---这里要明白一点容差是上下的。所有这里有不同。
         
             tolerance_shang = line_space+tolerance
             tolerance_xia =line_space-tolerance
          
           if local_line_space <=tolerance_shang  and  local_line_space>=tolerance_xia   then ---
           (
             endge_length_array[(endge_length_array.count) +1]= i
           
           )
                         
         
         )---end for oop_Eng
         ---选择边的数组就好
        
         polyop.setEdgeSelection input_poly  endge_length_array
        
     
        )--end classof poly
       
        ---同样在里面找到上面的函数应用到mesh
        --1.返回返回mesh的所有的边数
        --2.对当前的选择边转数组
        --3.比较距离。(这里面中要的是能找到返回点的坐标的函数)
        --4. 循环比较做处理。
        ---我现在的感觉是,搭建物体形体最好是用mesh 编辑物体最好到poly
       
      ---mesh 没有相应转换的参数。所以要是进行比较就比较困难了。这里就制作 poly 的编辑。
      
      )---end if
     
     
     )---end fn
     
     ----下面是根据面的大小做判断,根据面积 ,其实这个函数最好的就是对正边形做判断。处理。
     ---- 原来是利用面的返回值做计算
     fn  Equal_face  input_poly  tolerance = --函数 变量 input_face 是输入的poly tolerance 是容量的大小
     ( 
      local line_space_area =0 --初始化面积。
      local append_faces_area = #()
     
       if  superclassof input_poly ==GeometryClass  then
      (
        if classof input_poly == Editable_Poly then  --polyop.getEdgeSelection --这个以后还有很到的改善的地方,主要应用于层级的poly mesh
        (
         ---求总的面数
         total_output_face =  polyop.getNumFaces input_poly
           ---判断当前的面返回的点。是一个数组 非别是三点 四点 和多点
          being_Verts= polyop.getFaceSelection  input_poly as array
         if being_Verts.count==1 then ---确保选择的是一个面,这个处理的效果非常的好。
         ( 
         
         
           being_Verts_array =  polyop.getFaceVerts  input_poly   being_Verts[1]
           ----数量的表达
           being_Verts_array_count = being_Verts_array.count
           
            case being_Verts_array_count  of
         (
                            3:(
           ---因为这里返回的是点,还是需要用距离算出来。
                     date_dis_1 = polyop.getVert  input_poly  being_Verts_array[1]
                     date_dis_2 = polyop.getVert  input_poly  being_Verts_array[2]
            date_dis_3 = polyop.getVert  input_poly  being_Verts_array[3]
           
             line_space = distance  date_dis_1 date_dis_2
             line_space_1 = distance  date_dis_1 date_dis_3
             ---我做出了两个间距。下面我就计算假性的面积
            line_space_area = line_space *line_space_1 /2
           
           
           
          )
          4:(
             date_dis_1 = polyop.getVert  input_poly  being_Verts_array[1]
                      date_dis_2 = polyop.getVert  input_poly  being_Verts_array[2]
             date_dis_3 = polyop.getVert  input_poly  being_Verts_array[3]
             date_dis_4 = polyop.getVert  input_poly  being_Verts_array[4]
            ----这里面当做矩形看待处理面积
              line_space = distance  date_dis_1 date_dis_2
              line_space_1 = distance  date_dis_3 date_dis_4
            line_space_area = line_space *line_space_1
           
          )
          ----当等于5 6 7 8 时就是按下面的进行计算。
          default:(
           ----对于多个面的我同样是 假性的算出 矩形的面积。来处理
             date_dis_1 = polyop.getVert  input_poly  being_Verts_array[1]
                      date_dis_2 = polyop.getVert  input_poly  being_Verts_array[2]
             date_dis_3 = polyop.getVert  input_poly  being_Verts_array[3]
             date_dis_4 = polyop.getVert  input_poly  being_Verts_array[4]
            ----这里面当做矩形看待处理面积
              line_space = distance  date_dis_1 date_dis_2
              line_space_1 = distance  date_dis_3 date_dis_4
              line_space_area = line_space *line_space_1
           
           
          )

         )----case  of  
         -------------------下面就是循环处理所有面,通过比较面积处理。

         
       
         )else return false
        
          for i in 1 to total_output_face do
          (
           ---在查询面时同样也是要建立一个空组。
             being_Verts_array =  polyop.getFaceVerts  input_poly   i
           ----数量的表达
        ----通过测试表明,如果形体架线不正确,那么可能返回的面数很多,但是其实在面里又返回不了点 就会出现 undefined
           --所以加入排错
           if being_Verts_array ==undefined do  Continue
           being_Verts_array_count = being_Verts_array.count
           
            case ( being_Verts_array_count)  of
         (
                            3:(
           ---因为这里返回的是点,还是需要用距离算出来。
                     date_dis_1 = polyop.getVert  input_poly  being_Verts_array[1]
                     date_dis_2 = polyop.getVert  input_poly  being_Verts_array[2]
            date_dis_3 = polyop.getVert  input_poly  being_Verts_array[3]
           
             line_space = distance  date_dis_1 date_dis_2
             line_space_1 = distance  date_dis_1 date_dis_3
             ---我做出了两个间距。下面我就计算假性的面积
            local_line_space_area = line_space *line_space_1 /2
           if local_line_space_area <= line_space_area+tolerance and local_line_space_area >= line_space_area - tolerance  then
           (
                     append  append_faces_area i
            
            
           )
           
          )
          4:(
             date_dis_1 = polyop.getVert  input_poly  being_Verts_array[1]
                      date_dis_2 = polyop.getVert  input_poly  being_Verts_array[2]
             date_dis_3 = polyop.getVert  input_poly  being_Verts_array[3]
             date_dis_4 = polyop.getVert  input_poly  being_Verts_array[4]
            ----这里面当做矩形看待处理面积
              line_space = distance  date_dis_1 date_dis_2
              line_space_1 = distance  date_dis_3 date_dis_4
             local_line_space_area = line_space *line_space_1
           if local_line_space_area <= line_space_area+tolerance and local_line_space_area >= line_space_area - tolerance  then
           (
                     append  append_faces_area i
            
            
           )
           
          )
          ----当等于5 6 7 8 时就是按下面的进行计算。
          default:(
           ----对于多个面的我同样是 假性的算出 矩形的面积。来处理
             date_dis_1 = polyop.getVert  input_poly  being_Verts_array[1]
                      date_dis_2 = polyop.getVert  input_poly  being_Verts_array[2]
             date_dis_3 = polyop.getVert  input_poly  being_Verts_array[3]
             date_dis_4 = polyop.getVert  input_poly  being_Verts_array[4]
            ----这里面当做矩形看待处理面积
              line_space = distance  date_dis_1 date_dis_2
              line_space_1 = distance  date_dis_3 date_dis_4
               local_line_space_area = line_space *line_space_1
           if local_line_space_area <= line_space_area+tolerance and local_line_space_area >= line_space_area - tolerance  then
           (
                     append  append_faces_area i
            
            
           )
           
           
          )

         )----case  of
         
          
          )--end for face
         
          ---通过上面完成面的收集 ,下来就是进行选择处理。
          polyop.setFaceSelection  input_poly  append_faces_area
     
        
        )--enfd  poly
     
      ) ----end if super classof
     )---end fn
     
     ----对于边面的选择机制 ,我 还是要加入数组的相加处理的,这点很重要。
    global vertex_cun_gt =#(),edge_cun_gt =#(),polygon_cun_gt =#()

     try(cui.UnRegisterDialogBar gt_up_down_select)catch()-----这个是法则。
    try (DestroyDialog gt_up_down_select )catch()
    rollout gt_up_down_select  "容差选择" 160 height:89
    (
     spinner up_down_num_spn "上下容差值:" pos:[11,5] 135 height:16 range:[0,1e+008,0.01] type:#float scale:0.00001
     button equal_lenght_btn "同长度的边选择" pos:[16,27] 122 height:18
     button equal_face_btn "同面积的面选择" pos:[18,53] 122 height:18
     
     groupBox grp1 "因素内存" pos:[5,73] 151 height:93
     button xuan_btn1 "选" pos:[10,133] 35 height:19
     
     
     
     button dian_btn1 "点+" pos:[10,111] 35 height:19
     button qing_btn1 "清" pos:[10,91] 35 height:19
     button xuan_btn2 "选" pos:[57,133] 35 height:19
     
     
     
     button bian_btn1 "边+" pos:[57,111] 35 height:19
     button qing_btn2 "清" pos:[57,91] 35 height:19
     button xuan_btn3 "选" pos:[103,133] 35 height:19
     
     
     
     button mian_btn1 "面+" pos:[103,111] 35 height:19
     button qing_btn3 "清" pos:[103,91] 35 height:19
     on qing_btn1 pressed do
     (
      vertex_cun_gt =#()
     )
     on qing_btn2 pressed do
     (
      edge_cun_gt =#()
     )
     
     on qing_btn2 pressed do
     (
      polygon_cun_gt =#()
     )
     
     on xuan_btn1 pressed do
     (
      try (polyop.setVertSelection $  vertex_cun_gt )catch ()
     )
     on xuan_btn2 pressed do
     (
      try (polyop.setEdgeSelection  $  edge_cun_gt )catch ()
     )
     on xuan_btn3 pressed do
     (
      try (polyop.setFaceSelection   $  polygon_cun_gt )catch ()
     )
      on dian_btn1 pressed do
     (
      try (
       vertex_cun_gt +=( polyop.getVertSelection $ )as array  ---数组中有重复的显现 就这样了 要是循环在处理我觉得肯能算的会慢。
       --vertex_cun_gt += vertex_cun_gt
       
       
       
       )catch ()
     )
       on bian_btn1 pressed do
     (
      try (
       edge_cun_gt +=(polyop.getEdgeSelection  $ )as array  ---数组中有重复的显现 就这样了 要是循环在处理我觉得肯能算的会慢。
       --vertex_cun_gt += vertex_cun_gt
       
       
       
       )catch ()
     )
     on mian_btn1 pressed do
     (
      try (
       polygon_cun_gt +=(polyop.getFaceSelection  $ )as array  ---数组中有重复的显现 就这样了 要是循环在处理我觉得肯能算的会慢。
       --vertex_cun_gt += vertex_cun_gt
       
       
       
       )catch ()
     )
     
     
     
     
     
     on equal_lenght_btn pressed do
     (
      Equal_spline $ up_down_num_spn.value
     )---end on
      on equal_face_btn pressed do
     (
      Equal_face $ up_down_num_spn.value
     )---end on
     
     
     
    )

    ----------********************************************************

    ---段数的跳一个 选择一个,这样进行处理。点数的,面数的处理
    ---起初我是这么想的。用when 语句进行操作,单我按下按钮时,就是这样的,当我点击的线符合拓扑结构时。
    ---产生横向与纵向的连长,但是我后来就不这么想了。
    ---尤其是在听了路生的教导后。我不想在刷什么。我要做的工作是,在max的基础上,做东西。补不足。 max 能实现的,大家都在用,所以习惯了,
    ---不是很好改了。
    ---好了,写东西了。起初只是想写线的,现在看来,我要写 点的 边的, 面的  奇数 偶数的选择。2011.4.22 晚
    ---由于在选择中选择缺口 返回的是边,所以 所以这样按缺口选择的 估计有特定的函数,或有特定的组,
    ---这个我在后卖在考虑。
     fn odd_numbers_even_numbers input_poly type_t  odd_even  num  =
     (
      ---结构是点 边 面   在往下就是 奇数性 还有就是偶数性
      
        case of ---这个是我的手动的处理。所以这里面我只列举3 中情况进行处理。
      (

      (type_t == "select_vertex"):(
       
       local mod_array =#()
       local mod_back_array =#()
        Back_Verts_array = polyop.getVertSelection  input_poly
        Back_Verts_array =Back_Verts_array as array
       if Back_Verts_array.count !=0 then
       (
        Back_Verts_array =sort  Back_Verts_array --数组排列方便选择。
        
        for i in 1 to Back_Verts_array.count do
        (
         if  (mod  i num )as integer ==0 then
         (
             append   mod_array   Back_Verts_array[i]
          
         )else
         (
          append   mod_back_array   Back_Verts_array[i]
          
         )---end else
         
        )---end for
        
       
       
       if odd_even=="odd"then
       (
         polyop.setVertSelection   input_poly  mod_back_array
       )--end odd
       if odd_even=="even" then
       (
         polyop.setVertSelection   input_poly  mod_array
       )---end enen
       )----end back_vertex_array
       
      )---end ()
      (type_t == "select_edge"):(
       local mod_array =#()
       local mod_back_array =#()
        Back_Verts_array = polyop.getEdgeSelection  input_poly
        Back_Verts_array =Back_Verts_array as array
       if Back_Verts_array.count !=0 then
       (
        Back_Verts_array =sort  Back_Verts_array --数组排列方便选择。
        
        for i in 1 to Back_Verts_array.count do
        (
         if  (mod  i num )as integer ==0 then
         (
             append   mod_array   Back_Verts_array[i]
          
         )else
         (
          append   mod_back_array   Back_Verts_array[i]
          
         )---end else
         
        )---end for
        
       
       
       if odd_even=="odd"then
       (
         polyop.setEdgeSelection   input_poly  mod_back_array
       )--end odd
       if odd_even=="even" then
       (
         polyop.setEdgeSelection   input_poly  mod_array
       )---end enen
       
       )----end back_vertex_array
       
      )---end ()
      (type_t == "select_polygon"):(
       
       local mod_array =#()
       local mod_back_array =#()
        Back_Verts_array = polyop.getFaceSelection  input_poly
        Back_Verts_array =Back_Verts_array as array
       if Back_Verts_array.count !=0 then
       (
        Back_Verts_array =sort  Back_Verts_array --数组排列方便选择。
        
        for i in 1 to Back_Verts_array.count do
        (
         if  (mod  i num )as integer ==0 then
         (
             append   mod_array   Back_Verts_array[i]
          
         )else
         (
          append   mod_back_array   Back_Verts_array[i]
          
         )---end else
         
        )---end for
        
       
       
       if odd_even=="odd"then
       (
         polyop.setFaceSelection   input_poly  mod_back_array
       )--end odd
       if odd_even=="even" then
       (
         polyop.setFaceSelection   input_poly  mod_array
       )---end enen
       
       )else return  false ----end back_vertex_array
       
       
       
      )---end ()


       )---enf case
     )---end fn
     
    ---我觉得点的选择可以由面点会来,这个就不用写了。其实原来也是有面转成点,这个不是很费时间。
    ---我做的工具也是配合max 的命令一期操作的,所以这个就不选了。

     ------------------------------------------------------------------------------------- 
      
      
    fn max_2011_mode_style input_poly type_t ring_and_loop  by_num =
    (

    ---针对于我想的这里算法。来对点线面进行处理。我的方法就是
    --1.(先以线为例说明点和面都是这里过度的。)试验的对像确保是一个可操作的对象结构。
    --2.得知序列返回数组,返回之前选择的 组内对应的号数。 在组内做递加 和递减 最小不能小于1 最大不能超过组本身的数
    --3.两个数组相加 在进行边的选择,
    --4.之后依次展开 处理。
    --5.结构是:
    ---------------1. 点线面的大结构
    ---------------2.在处理横选择 还是纵选择的问题
    ---------------3. 选择处理
      case of ---这个是我的手动的处理。所以这里面我只列举3 中情况进行处理。
      (
       
      (type_t == "select_vertex"):(
       ---2011.4.23 2.35 对于点击莫一个线向外边散开,隔一个选择一个思路我是有了。
       
       --在这个的操作中,对于线我已经做好,对于面我可以转换成线,在操作,最后在返回面,造成
       --假象上的对于面的处理。其实还是从线的方式出发。
       --对于点 在转换成线的过程中,就不是很好办理。我是可以通过线 转点在选择点,
       --从研究上来说是可行的,但是从应用 和美术来说极为不好,所以这部分呢不写 不要了。
       --想要的效果同样是能做出来。
       
      )---end ()

      (type_t == "select_edge"):(
       ---2011.4.23 2.35 对于点击莫一个线向外边散开,隔一个选择一个思路我是有了。
       ---判断选择线是一个进行操作,这个是我要的效果。
       local up_array =#()
       local down_array = #()
       local total_array =()---向上向下的数组加在一起,就是我要选择的东西。
       
       
       Back_Verts_array = polyop.getEdgeSelection  input_poly
       Back_Verts_array=Back_Verts_array as array
       if  Back_Verts_array.count ==1 then
       (
       if ring_and_loop=="ring"then
       (
        input_poly.EditablePoly.SelectEdgeRing ()
        ---加入循环命令。
        --查看现在选择的号数,和之前的查找编号。如果数组的个数小于两个是什么都不做的。
        form_Back_Verts_array= Back_Verts_array[1] ---这里面保证是一个。
        
        now_Back_Verts_array = polyop.getEdgeSelection  input_poly
        now_Back_Verts_array=now_Back_Verts_array as array
        now_Back_Verts_array_count =now_Back_Verts_array.count ---数量
        ---下一步就是查找顶点所在的个数,在一个模型中,顶点数组肯定是不会有重复的。
        if now_Back_Verts_array_count <3 then return false ----如果数组中就这有两个的话
         ---循环 隔选就没有意义了。
        
        ----在数组中查找肯定是能查找出来,这个是肯定的。
         unm_edge = findItem   now_Back_Verts_array  form_Back_Verts_array
        -----寄存选择的线在数组中的位置。
        local true_tt =true
        while true_tt do
        ( 
         --append up_array 这里面我为什么想放在这里,我是怕溜掉了unm_edge
         --后来想想他还像下循环,都这样的话旧哟哟重复的了
         -- 这里我不查找数组的重复,我最后做个加法运算。加上他就行了,这样快。
         unm_edge+=by_num
         ----这里就是循环一遍把东西往数组中加入一遍。
         if unm_edge<= now_Back_Verts_array_count then
         (
         append up_array now_Back_Verts_array[unm_edge]
         )
         
         if unm_edge>=now_Back_Verts_array_count then
         (
          true_tt=false
          
         )
         
        )---end while
        
        local true_true =true
        while true_true do
        ( 
         --append up_array 这里面我为什么想放在这里,我是怕溜掉了unm_edge
         --后来想想他还像下循环,都这样的话旧哟哟重复的了
         -- 这里我不查找数组的重复,我最后做个加法运算。加上他就行了,这样快。
         unm_edge-=by_num
         ----这里就是循环一遍把东西往数组中加入一遍。
         if unm_edge >=1 then
         (
         append down_array  now_Back_Verts_array[unm_edge]
         )
         
         if unm_edge <=1 then
         (
          true_true=false
          
         )
        
         
        )---end while
        total_array =up_array +down_array +Back_Verts_array

         polyop.setEdgeSelection   input_poly  total_array
        
       )----end if ring
       
       
       if ring_and_loop=="loop"then
       (
        input_poly.EditablePoly.SelectEdgeLoop ()
        ---加入循环命令。
        --查看现在选择的号数,和之前的查找编号。如果数组的个数小于两个是什么都不做的。
        form_Back_Verts_array= Back_Verts_array[1] ---这里面保证是一个。
        
        now_Back_Verts_array = polyop.getEdgeSelection  input_poly
        now_Back_Verts_array=now_Back_Verts_array as array
        now_Back_Verts_array_count =now_Back_Verts_array.count ---数量
        ---下一步就是查找顶点所在的个数,在一个模型中,顶点数组肯定是不会有重复的。
        if now_Back_Verts_array_count <3 then return false ----如果数组中就这有两个的话
         ---循环 隔选就没有意义了。
        
        ----在数组中查找肯定是能查找出来,这个是肯定的。
         unm_edge = findItem   now_Back_Verts_array  form_Back_Verts_array
        -----寄存选择的线在数组中的位置。
        local true_tt =true
        while true_tt do
        ( 
         --append up_array 这里面我为什么想放在这里,我是怕溜掉了unm_edge
         --后来想想他还像下循环,都这样的话旧哟哟重复的了
         -- 这里我不查找数组的重复,我最后做个加法运算。加上他就行了,这样快。
         unm_edge+=by_num
         ----这里就是循环一遍把东西往数组中加入一遍。
         if unm_edge<= now_Back_Verts_array_count then
         (
         append up_array now_Back_Verts_array[unm_edge]
         )
         
         if unm_edge>=now_Back_Verts_array_count then
         (
          true_tt=false
          
         )
         
        )---end while
        
        local true_true =true
        while true_true do
        ( 
         --append up_array 这里面我为什么想放在这里,我是怕溜掉了unm_edge
         --后来想想他还像下循环,都这样的话旧哟哟重复的了
         -- 这里我不查找数组的重复,我最后做个加法运算。加上他就行了,这样快。
         unm_edge-=by_num
         ----这里就是循环一遍把东西往数组中加入一遍。
         if unm_edge >=1 then
         (
         append down_array  now_Back_Verts_array[unm_edge]
         )
         
         if unm_edge <=1 then
         (
          true_true=false
          
         )
        
         
        )---end while
        total_array =up_array +down_array +Back_Verts_array

         polyop.setEdgeSelection   input_poly  total_array
        
       )----end if loop
       
       
      )---end if back_vertx_array.count
        
      )---end ()

      (type_t == "select_polygon"):(
       ---2011.4.23 2.35 对于点击莫一个线向外边散开,隔一个选择一个思路我是有了。
       
       ---判断选择线是一个进行操作,这个是我要的效果。
       local up_array =#()
       local down_array = #()
       local total_array =()---向上向下的数组加在一起,就是我要选择的东西。
       
       
       Back_Verts_array = polyop.getFaceSelection input_poly
       Back_Verts_array=Back_Verts_array as array
       if  Back_Verts_array.count ==1 then
       (
       if ring_and_loop=="ring"then
       (
         
        ---加入循环命令。
        --查看现在选择的号数,和之前的查找编号。如果数组的个数小于两个是什么都不做的。
        form_Back_Verts_array= Back_Verts_array[1] ---这里面保证是一个。
        --input_poly.EditablePoly.SelectEdgeRing ()
        --用面返回边,用边做循环 返回面,在进行面的处理。
        polygon_to_edge_array = polyop.getFaceEdges input_poly  form_Back_Verts_array
        ---返回的第一个是ring 第二个是loop
         polyop.setEdgeSelection  input_poly  polygon_to_edge_array[1]--这里是转折点
         input_poly.EditablePoly.SelectEdgeRing ()
        input_poly.EditablePoly.ConvertSelection  #Edge #Face --转成面
        
        now_Back_Verts_array = polyop.getFaceSelection  input_poly
        now_Back_Verts_array=now_Back_Verts_array as array
        now_Back_Verts_array_count =now_Back_Verts_array.count ---数量
        ---下一步就是查找顶点所在的个数,在一个模型中,顶点数组肯定是不会有重复的。
        if now_Back_Verts_array_count <3 then return false ----如果数组中就这有两个的话
         ---循环 隔选就没有意义了。
        
        ----在数组中查找肯定是能查找出来,这个是肯定的。
         unm_edge = findItem   now_Back_Verts_array  form_Back_Verts_array
        -----寄存选择的线在数组中的位置。
        local true_tt =true
        while true_tt do
        ( 
         --append up_array 这里面我为什么想放在这里,我是怕溜掉了unm_edge
         --后来想想他还像下循环,都这样的话旧哟哟重复的了
         -- 这里我不查找数组的重复,我最后做个加法运算。加上他就行了,这样快。
         unm_edge+=by_num
         ----这里就是循环一遍把东西往数组中加入一遍。
         if unm_edge<= now_Back_Verts_array_count then
         (
         append up_array now_Back_Verts_array[unm_edge]
         )
         
         if unm_edge>=now_Back_Verts_array_count then
         (
          true_tt=false
          
         )
         
        )---end while
        
        local true_true =true
        while true_true do
        ( 
         --append up_array 这里面我为什么想放在这里,我是怕溜掉了unm_edge
         --后来想想他还像下循环,都这样的话旧哟哟重复的了
         -- 这里我不查找数组的重复,我最后做个加法运算。加上他就行了,这样快。
         unm_edge-=by_num
         ----这里就是循环一遍把东西往数组中加入一遍。
         if unm_edge >=1 then
         (
         append down_array  now_Back_Verts_array[unm_edge]
         )
         
         if unm_edge <=1 then
         (
          true_true=false
          
         )
        
         
        )---end while
        total_array =up_array +down_array +Back_Verts_array

         polyop.setFaceSelection  input_poly  total_array
        
       )----end if ring
       
       
       if ring_and_loop=="loop"then
       (
        
         
        ---加入循环命令。
        --查看现在选择的号数,和之前的查找编号。如果数组的个数小于两个是什么都不做的。
        form_Back_Verts_array= Back_Verts_array[1] ---这里面保证是一个。
        --input_poly.EditablePoly.SelectEdgeRing ()
        --用面返回边,用边做循环 返回面,在进行面的处理。
        polygon_to_edge_array = polyop.getFaceEdges input_poly  form_Back_Verts_array
        ---返回的第一个是ring 第二个是loop
         polyop.setEdgeSelection  input_poly  polygon_to_edge_array[2]--这里是转折点
        -- input_poly.EditablePoly.SelectEdgeLoop ()
        input_poly.EditablePoly.SelectEdgeRing ()---这里我变化了数组个数所以都是要ring
        input_poly.EditablePoly.ConvertSelection  #Edge #Face --转成面
        
        now_Back_Verts_array = polyop.getFaceSelection  input_poly
        now_Back_Verts_array=now_Back_Verts_array as array
        now_Back_Verts_array_count =now_Back_Verts_array.count ---数量
        ---下一步就是查找顶点所在的个数,在一个模型中,顶点数组肯定是不会有重复的。
        if now_Back_Verts_array_count <3 then return false ----如果数组中就这有两个的话
         ---循环 隔选就没有意义了。
        
        ----在数组中查找肯定是能查找出来,这个是肯定的。
         unm_edge = findItem   now_Back_Verts_array  form_Back_Verts_array
        -----寄存选择的线在数组中的位置。
        local true_tt =true
        while true_tt do
        ( 
         --append up_array 这里面我为什么想放在这里,我是怕溜掉了unm_edge
         --后来想想他还像下循环,都这样的话旧哟哟重复的了
         -- 这里我不查找数组的重复,我最后做个加法运算。加上他就行了,这样快。
         unm_edge+=by_num
         ----这里就是循环一遍把东西往数组中加入一遍。
         if unm_edge<= now_Back_Verts_array_count then
         (
         append up_array now_Back_Verts_array[unm_edge]
         )
         
         if unm_edge>=now_Back_Verts_array_count then
         (
          true_tt=false
          
         )
         
        )---end while
        
        local true_true =true
        while true_true do
        ( 
         --append up_array 这里面我为什么想放在这里,我是怕溜掉了unm_edge
         --后来想想他还像下循环,都这样的话旧哟哟重复的了
         -- 这里我不查找数组的重复,我最后做个加法运算。加上他就行了,这样快。
         unm_edge-=by_num
         ----这里就是循环一遍把东西往数组中加入一遍。
         if unm_edge >=1 then
         (
         append down_array  now_Back_Verts_array[unm_edge]
         )
         
         if unm_edge <=1 then
         (
          true_true=false
          
         )
        
         
        )---end while
        total_array =up_array +down_array +Back_Verts_array

         polyop.setFaceSelection  input_poly  total_array

        
       )----end if loop
       
       
         )---end if back_vertx_array.count
     
      )---end ()    
       
      )----end case

     
    )-------end fn max_2011


     try(cui.UnRegisterDialogBar gt_element__)catch()-----这个是法则。
    try (DestroyDialog gt_element__ )catch()
    rollout gt_element__ "编辑步幅因素" 160 height:297
    (
     spinner guolu_spn "过滤步幅" pos:[34,8] 99 height:16 enabled:true range:[0,100,2] type:#integer scale:0.1
     button select_vertex_odd_btn "选择点的奇数过滤" pos:[21,29] 118 height:18
     button select_vertex_even_btn "选择点的偶数过滤" pos:[21,49] 118 height:18
     button select_edge_even_btn "选择边的偶数过滤" pos:[21,96] 118 height:18
     button select_edge_odd_btn "选择边的奇数过滤" pos:[21,77] 118 height:18
     button select_face_even_btn "选择面的偶数过滤" pos:[21,145] 118 height:18
     button select_face_odd_btn "选择面的奇数过滤" pos:[21,125] 118 height:18
     spinner max_2011_spn "过滤步幅" pos:[34,172] 99 height:16 enabled:true range:[0,100,2] type:#integer scale:0.1
     button select_edge_ring_btn "选择边的ring" pos:[21,196] 118 height:18
     button select_edge_loop_btn "选择边的loop" pos:[21,216] 118 height:18
     button select_face_loop_btn "选择面的loop" pos:[21,263] 118 height:18
     button select_face_ring_btn "选择面的ring" pos:[21,244] 118 height:18
     on select_vertex_odd_btn pressed do
     (
      try (  odd_numbers_even_numbers $ "select_vertex" "odd" guolu_spn.value )catch ()
     )--end on
     
     on select_vertex_even_btn pressed do
     (
      try (  odd_numbers_even_numbers $ "select_vertex" "even" guolu_spn.value )catch ()
     )--end on  
      on select_edge_odd_btn pressed do
     (
      try ( odd_numbers_even_numbers $ "select_edge" "odd" guolu_spn.value )catch ()
     )--end on  
     
       on select_edge_even_btn pressed do
     (
      try (  odd_numbers_even_numbers $ "select_edge" "even" guolu_spn.value )catch ()
     )--end on  
     
        on select_face_even_btn pressed do
     (
      try (  odd_numbers_even_numbers $ "select_polygon" "odd" guolu_spn.value )catch ()
     )--end on
     
        on select_face_odd_btn pressed do
     (
      try (  odd_numbers_even_numbers $ "select_polygon" "even" guolu_spn.value )catch ()
     )--end on  
     
     
     
     
         on select_edge_ring_btn  pressed do
     (
      try (  max_2011_mode_style $ "select_edge" "ring" max_2011_spn.value )catch ()
     )--end on  
     
         on select_edge_loop_btn  pressed do
     (
      try (  max_2011_mode_style $ "select_edge" "loop" max_2011_spn.value )catch ()
     )--end on   
     
         on select_face_loop_btn  pressed do
     (
      try (  max_2011_mode_style $ "select_polygon" "loop" max_2011_spn.value )catch ()
     )--end on  
     
          on select_face_ring_btn  pressed do
     (
      try (  max_2011_mode_style $ "select_polygon" "ring" max_2011_spn.value )catch ()
     )--end on  

     
     
     
    )
    ----****************************************************************************


    -----还有一个就是随机的选择面熟
    ----这个思路相对明确一些,判断是不是 poly mrsh 到面层级
    ---2. 收集所有面的数组。这里有两种情况
     ---3我要随机的选择100 个面,还有就是我要递增的选择100 个面。
     ---我是这样随即。random 1 到面熟。 选择多少个进行多少次,加到数组
     ----并且我们还不能叫数组有重复的。就好了。
     ---在下面由一个“变体”的功能,其实不错。我是这样考虑的。
     ---1.知道poly的因素数,判断面数所在因素数,这样在选择相应的因素数, 这里面可能有多面在通一个因素上
     ---2.这样这时要叫因素具有唯一性就好。
    --下面开始写随即函数。
    --非常重要的一点。随即函数 在在poly层进行。并且是在基层处理。在这个基层之上
    -- 随机的  点  线  面   。 就是说  如果我预先选择了  点 线 面 就是在选择的基层上进行随机的处理,如果没有就是全局的处理。
    -- 其实还有一点就是因素的随机。这个在后来也是很重要的。这个要记住。
    --在选择里我加入10 % 处理,但是一定到时候要转整数。因为边面点,不存在. 几的问题。
     fn poly_random_type  input_poly  type  count_t  percentage = --函数是 随机选择因素的。type 是因素的种类 (暂时不考虑因素的最后一个)
      --count_t 按数量 percentage 按百分比。 input_poly 输入者
     (
        case of ---这个是我的手动的处理。所以这里面我只列举3 中情况进行处理。
      (

      (type == "vertex"): (
       
       local  vertes_count__ =#()
       ------这里面由两种选择,数量的选择 ,还有就是 % 的选择,到最后我倒ui中要最一个事件
       ----当count_t percentage 同时不为零,报错机制触发,当 count_t ==0 那么 percentage==10 当percentage ==0 那么count_t ==1
       ----选择好选择类型在,处理,我是当前选择了。还是没有选择,进行处理。
       ---先做数量的选择
       if  percentage ==0 and count_t ==0 then return false
       if  percentage !=0 and count_t !=0 then return false  ---这样的报错机制就好了。
        
        if percentage ==0 and count_t !=0 then -----拾取个数的情况。
        (
          local Back_Verts_array
        ---查看当前选择的点,分两种情况进行。数组为空与不为空,分为全局与局部的关系。
         total_Verts_array = polyop.getNumVerts input_poly
         ---全局顶点数,和当前选择的数组。
         if count_t >total_Verts_array then count_t =total_Verts_array ------保证输入的个数不超标
          Back_Verts_array = polyop.getVertSelection  input_poly
                        
         if (Back_Verts_array as array) .count ==0 then --- 全局选择
         (
          for i in 1 to count_t do
          (
           ---这里要加入数组唯一化机制
           random_count=  random 1 total_Verts_array
           if  findItem vertes_count__  random_count ==0 then
          (
           ---因为我没有循环点。所以不用加入 undefined 机制。 在询问面 返回点的函数时,有时面本来是多了,但是在循环面找点是 就是
           ---undefined  这个自己一定要记住。
           append vertes_count__ random_count
          )---end if finditem
          
          )---end for total
         
         
         )---end back
          if( Back_Verts_array as array) .count !=0 then --- 全局选择
         (
          Back_Verts_array=(Back_Verts_array as array) --这中方式其实就是临时的被改。
         
          if count_t > Back_Verts_array.count then count_t =Back_Verts_array.count  ------保证输入的个数不超标
          for i in 1 to count_t do --同是给输入的数量一个定义
          (
           random_count=   Back_Verts_array [ (random 1 Back_Verts_array.count )]----局部内的点数。
          
           if  findItem vertes_count__  random_count ==0 then
          (
           ---因为我没有循环点。所以不用加入 undefined 机制。 在询问面 返回点的函数时,有时面本来是多了,但是在循环面找点是 就是
           ---undefined  这个自己一定要记住。
           append vertes_count__ random_count
          )---end if finditem
     
          )---end for  i in 1 to count_t ..
     
         )----end if BACK

        
        )---end if percenntage
        if percentage !=0 and count_t ==0 then  ----%比的情况,这个很好。
        (
         ---% 情况其实可以和之前的一模一样,也是吧% 的数组线算出来。
         local Back_Verts_array ,total_Verts_array
        ---查看当前选择的点,分两种情况进行。数组为空与不为空,分为全局与局部的关系。
         total_Verts_array = polyop.getNumVerts input_poly
         ---全局顶点数,和当前选择的数组。
         /*
           percentage_count=  total_Verts_array *percentage /100
           percentage_count = percentage_count as integer
         if percentage_count >total_Verts_array then percentage_count =total_Verts_array ------保证输入的个数不超标
          */
          Back_Verts_array = polyop.getVertSelection  input_poly
                        
         if (Back_Verts_array as array) .count ==0 then --- 全局选择
         ( 
          percentage_count=  total_Verts_array *percentage /100
           percentage_count = percentage_count as integer
         if percentage_count >total_Verts_array then percentage_count =total_Verts_array ------保证输入的个数不超标
         
          local true_tt =true
           while ( true_tt)do
          (
          --for i in 1 to total_Verts_array do --因为我在上面进行了数量的把控 所以这里面是在真个中循环
         ---我明白了这里就不用加循环了。 while本身就是循环 所以这里就这样就慢死了 
         
          (
           ---这里要加入数组唯一化机制
           random_count=  random 1 total_Verts_array
           ---这里面我要说下,因为是100 % 但是由于随机 经常取一样的值。就是100% 的点中 在跑去相同,所以会出现 不满的情况。
           --我应该最死循环, 知道数组中的数量 符合他的 % 分数。
          
           if  findItem vertes_count__  random_count ==0 then
          (
           ---因为我没有循环点。所以不用加入 undefined 机制。 在询问面 返回点的函数时,有时面本来是多了,但是在循环面找点是 就是
           ---undefined  这个自己一定要记住。
           append vertes_count__ random_count
          )---end if finditem
          
          )---end for total
          if (vertes_count__.count ==percentage_count ) then
          (
           true_tt=false
          )
         
            )---end while
         )---end back
         -----------------------2011.4.22 过了一天接着写
         if (Back_Verts_array as array) .count !=0 then --- 全局选择
         (
          percentage_count=  ((Back_Verts_array as array) .count) *percentage /100
           percentage_count = percentage_count as integer
         if percentage_count >((Back_Verts_array as array) .count) then percentage_count =((Back_Verts_array as array) .count) ------保证输入的个数不超标
         
          local true_tt =true
           while ( true_tt)do
          (
          --for i in 1 to total_Verts_array do --因为我在上面进行了数量的把控 所以这里面是在真个中循环
         ---我明白了这里就不用加循环了。 while本身就是循环 所以这里就这样就慢死了 
          (
           ---这里要加入数组唯一化机制
          -- random_count=  random 1 total_Verts_array
           Back_Verts_array=Back_Verts_array as array  ---
           ---2011.4.22 测试不行是,是忘了转会数组,这个很重要。
           random_count=   Back_Verts_array [ (random 1 Back_Verts_array.count )]----局部内的点数。
           ---这里面我要说下,因为是100 % 但是由于随机 经常取一样的值。就是100% 的点中 在跑去相同,所以会出现 不满的情况。
           --我应该最死循环, 知道数组中的数量 符合他的 % 分数。
          
           if  findItem vertes_count__  random_count ==0 then
          (
           ---因为我没有循环点。所以不用加入 undefined 机制。 在询问面 返回点的函数时,有时面本来是多了,但是在循环面找点是 就是
           ---undefined  这个自己一定要记住。
           append vertes_count__ random_count
          )---end if finditem
          
          )---end for total
          if (vertes_count__.count ==percentage_count ) then
          (
           true_tt=false
          )
         
            )---end while
      
         )----end back

        
        )--end if percentage

       
       
        polyop.setVertSelection   input_poly  vertes_count__
       
      )--end ()

      (type == "edge"): (
       
       local  vertes_count__ =#()
       ------这里面由两种选择,数量的选择 ,还有就是 % 的选择,到最后我倒ui中要最一个事件
       ----当count_t percentage 同时不为零,报错机制触发,当 count_t ==0 那么 percentage==10 当percentage ==0 那么count_t ==1
       ----选择好选择类型在,处理,我是当前选择了。还是没有选择,进行处理。
       ---先做数量的选择
       if  percentage ==0 and count_t ==0 then return false
       if  percentage !=0 and count_t !=0 then return false  ---这样的报错机制就好了。
        
        if percentage ==0 and count_t !=0 then -----拾取个数的情况。
        (
          local Back_Verts_array
        ---查看当前选择的点,分两种情况进行。数组为空与不为空,分为全局与局部的关系。
         total_Verts_array = polyop.getNumEdges  input_poly
         ---全局顶点数,和当前选择的数组。
         if count_t >total_Verts_array then count_t =total_Verts_array ------保证输入的个数不超标
          Back_Verts_array = polyop.getEdgeSelection   input_poly
                        
         if (Back_Verts_array as array) .count ==0 then --- 全局选择
         (
          for i in 1 to count_t do
          (
           ---这里要加入数组唯一化机制
           random_count=  random 1 total_Verts_array
           if  findItem vertes_count__  random_count ==0 then
          (
           ---因为我没有循环点。所以不用加入 undefined 机制。 在询问面 返回点的函数时,有时面本来是多了,但是在循环面找点是 就是
           ---undefined  这个自己一定要记住。
           append vertes_count__ random_count
          )---end if finditem
          
          )---end for total
         
         
         )---end back
          if( Back_Verts_array as array) .count !=0 then --- 全局选择
         (
          Back_Verts_array=(Back_Verts_array as array) --这中方式其实就是临时的被改。
         
          if count_t > Back_Verts_array.count then count_t =Back_Verts_array.count  ------保证输入的个数不超标
          for i in 1 to count_t do --同是给输入的数量一个定义
          (
           random_count=   Back_Verts_array [ (random 1 Back_Verts_array.count )]----局部内的点数。
          
           if  findItem vertes_count__  random_count ==0 then
          (
           ---因为我没有循环点。所以不用加入 undefined 机制。 在询问面 返回点的函数时,有时面本来是多了,但是在循环面找点是 就是
           ---undefined  这个自己一定要记住。
           append vertes_count__ random_count
          )---end if finditem
     
          )---end for  i in 1 to count_t ..
     
         )----end if BACK

        
        )---end if percenntage
        if percentage !=0 and count_t ==0 then  ----%比的情况,这个很好。
        (
         ---% 情况其实可以和之前的一模一样,也是吧% 的数组线算出来。
         local Back_Verts_array ,total_Verts_array
        ---查看当前选择的点,分两种情况进行。数组为空与不为空,分为全局与局部的关系。
         total_Verts_array = polyop.getNumEdges   input_poly
         ---全局顶点数,和当前选择的数组。
         /*
           percentage_count=  total_Verts_array *percentage /100
           percentage_count = percentage_count as integer
         if percentage_count >total_Verts_array then percentage_count =total_Verts_array ------保证输入的个数不超标
          */
          Back_Verts_array = polyop.getEdgeSelection   input_poly
                        
         if (Back_Verts_array as array) .count ==0 then --- 全局选择
         ( 
          percentage_count=  total_Verts_array *percentage /100
           percentage_count = percentage_count as integer
         if percentage_count >total_Verts_array then percentage_count =total_Verts_array ------保证输入的个数不超标
         
          local true_tt =true
           while ( true_tt)do
          (
          --for i in 1 to total_Verts_array do --因为我在上面进行了数量的把控 所以这里面是在真个中循环
         ---我明白了这里就不用加循环了。 while本身就是循环 所以这里就这样就慢死了 
         
          (
           ---这里要加入数组唯一化机制
           random_count=  random 1 total_Verts_array
           ---这里面我要说下,因为是100 % 但是由于随机 经常取一样的值。就是100% 的点中 在跑去相同,所以会出现 不满的情况。
           --我应该最死循环, 知道数组中的数量 符合他的 % 分数。
          
           if  findItem vertes_count__  random_count ==0 then
          (
           ---因为我没有循环点。所以不用加入 undefined 机制。 在询问面 返回点的函数时,有时面本来是多了,但是在循环面找点是 就是
           ---undefined  这个自己一定要记住。
           append vertes_count__ random_count
          )---end if finditem
          
          )---end for total
          if (vertes_count__.count ==percentage_count ) then
          (
           true_tt=false
          )
         
            )---end while
         )---end back
         -----------------------2011.4.22 过了一天接着写
         if (Back_Verts_array as array) .count !=0 then --- 全局选择
         (
          percentage_count=  ((Back_Verts_array as array) .count) *percentage /100
           percentage_count = percentage_count as integer
         if percentage_count >((Back_Verts_array as array) .count) then percentage_count =((Back_Verts_array as array) .count) ------保证输入的个数不超标
         
          local true_tt =true
           while ( true_tt)do
          (
          --for i in 1 to total_Verts_array do --因为我在上面进行了数量的把控 所以这里面是在真个中循环
         ---我明白了这里就不用加循环了。 while本身就是循环 所以这里就这样就慢死了 
          (
           ---这里要加入数组唯一化机制
          -- random_count=  random 1 total_Verts_array
           Back_Verts_array=Back_Verts_array as array  ---
           ---2011.4.22 测试不行是,是忘了转会数组,这个很重要。
           random_count=   Back_Verts_array [ (random 1 Back_Verts_array.count )]----局部内的点数。
           ---这里面我要说下,因为是100 % 但是由于随机 经常取一样的值。就是100% 的点中 在跑去相同,所以会出现 不满的情况。
           --我应该最死循环, 知道数组中的数量 符合他的 % 分数。
          
           if  findItem vertes_count__  random_count ==0 then
          (
           ---因为我没有循环点。所以不用加入 undefined 机制。 在询问面 返回点的函数时,有时面本来是多了,但是在循环面找点是 就是
           ---undefined  这个自己一定要记住。
           append vertes_count__ random_count
          )---end if finditem
          
          )---end for total
          if (vertes_count__.count ==percentage_count ) then
          (
           true_tt=false
          )
         
            )---end while
      
         )----end back

        
        )--end if percentage

       
       
        polyop.setEdgeSelection   input_poly  vertes_count__
       
       
       
      )----end ()

      (type == "polygon"):(
       
       local  vertes_count__ =#()
       ------这里面由两种选择,数量的选择 ,还有就是 % 的选择,到最后我倒ui中要最一个事件
       ----当count_t percentage 同时不为零,报错机制触发,当 count_t ==0 那么 percentage==10 当percentage ==0 那么count_t ==1
       ----选择好选择类型在,处理,我是当前选择了。还是没有选择,进行处理。
       ---先做数量的选择
       if  percentage ==0 and count_t ==0 then return false
       if  percentage !=0 and count_t !=0 then return false  ---这样的报错机制就好了。
        
        if percentage ==0 and count_t !=0 then -----拾取个数的情况。
        (
          local Back_Verts_array
        ---查看当前选择的点,分两种情况进行。数组为空与不为空,分为全局与局部的关系。
         total_Verts_array = polyop.getNumFaces  input_poly
         ---全局顶点数,和当前选择的数组。
         if count_t >total_Verts_array then count_t =total_Verts_array ------保证输入的个数不超标
          Back_Verts_array = polyop.getFaceSelection   input_poly
                        
         if (Back_Verts_array as array) .count ==0 then --- 全局选择
         (
          for i in 1 to count_t do
          (
           ---这里要加入数组唯一化机制
           random_count=  random 1 total_Verts_array
           if  findItem vertes_count__  random_count ==0 then
          (
           ---因为我没有循环点。所以不用加入 undefined 机制。 在询问面 返回点的函数时,有时面本来是多了,但是在循环面找点是 就是
           ---undefined  这个自己一定要记住。
           append vertes_count__ random_count
          )---end if finditem
          
          )---end for total
         
         
         )---end back
          if( Back_Verts_array as array) .count !=0 then --- 全局选择
         (
          Back_Verts_array=(Back_Verts_array as array) --这中方式其实就是临时的被改。
         
          if count_t > Back_Verts_array.count then count_t =Back_Verts_array.count  ------保证输入的个数不超标
          for i in 1 to count_t do --同是给输入的数量一个定义
          (
           random_count=   Back_Verts_array [ (random 1 Back_Verts_array.count )]----局部内的点数。
          
           if  findItem vertes_count__  random_count ==0 then
          (
           ---因为我没有循环点。所以不用加入 undefined 机制。 在询问面 返回点的函数时,有时面本来是多了,但是在循环面找点是 就是
           ---undefined  这个自己一定要记住。
           append vertes_count__ random_count
          )---end if finditem
     
          )---end for  i in 1 to count_t ..
     
         )----end if BACK

        
        )---end if percenntage
        if percentage !=0 and count_t ==0 then  ----%比的情况,这个很好。
        (
         ---% 情况其实可以和之前的一模一样,也是吧% 的数组线算出来。
         local Back_Verts_array ,total_Verts_array
        ---查看当前选择的点,分两种情况进行。数组为空与不为空,分为全局与局部的关系。
         total_Verts_array = polyop.getNumFaces  input_poly
         ---全局顶点数,和当前选择的数组。
         /*
           percentage_count=  total_Verts_array *percentage /100
           percentage_count = percentage_count as integer
         if percentage_count >total_Verts_array then percentage_count =total_Verts_array ------保证输入的个数不超标
          */
          Back_Verts_array = polyop.getFaceSelection   input_poly
                        
         if (Back_Verts_array as array) .count ==0 then --- 全局选择
         ( 
          percentage_count=  total_Verts_array *percentage /100
           percentage_count = percentage_count as integer
         if percentage_count >total_Verts_array then percentage_count =total_Verts_array ------保证输入的个数不超标
         
          local true_tt =true
           while ( true_tt)do
          (
          --for i in 1 to total_Verts_array do --因为我在上面进行了数量的把控 所以这里面是在真个中循环
         ---我明白了这里就不用加循环了。 while本身就是循环 所以这里就这样就慢死了 
         
          (
           ---这里要加入数组唯一化机制
           random_count=  random 1 total_Verts_array
           ---这里面我要说下,因为是100 % 但是由于随机 经常取一样的值。就是100% 的点中 在跑去相同,所以会出现 不满的情况。
           --我应该最死循环, 知道数组中的数量 符合他的 % 分数。
          
           if  findItem vertes_count__  random_count ==0 then
          (
           ---因为我没有循环点。所以不用加入 undefined 机制。 在询问面 返回点的函数时,有时面本来是多了,但是在循环面找点是 就是
           ---undefined  这个自己一定要记住。
           append vertes_count__ random_count
          )---end if finditem
          
          )---end for total
          if (vertes_count__.count ==percentage_count ) then
          (
           true_tt=false
          )
         
            )---end while
         )---end back
         -----------------------2011.4.22 过了一天接着写
         if (Back_Verts_array as array) .count !=0 then --- 全局选择
         (
          percentage_count=  ((Back_Verts_array as array) .count) *percentage /100
           percentage_count = percentage_count as integer
         if percentage_count >((Back_Verts_array as array) .count) then percentage_count =((Back_Verts_array as array) .count) ------保证输入的个数不超标
         
          local true_tt =true
           while ( true_tt)do
          (
          --for i in 1 to total_Verts_array do --因为我在上面进行了数量的把控 所以这里面是在真个中循环
         ---我明白了这里就不用加循环了。 while本身就是循环 所以这里就这样就慢死了 
          (
           ---这里要加入数组唯一化机制
          -- random_count=  random 1 total_Verts_array
           Back_Verts_array=Back_Verts_array as array  ---
           ---2011.4.22 测试不行是,是忘了转会数组,这个很重要。
           random_count=   Back_Verts_array [ (random 1 Back_Verts_array.count )]----局部内的点数。
           ---这里面我要说下,因为是100 % 但是由于随机 经常取一样的值。就是100% 的点中 在跑去相同,所以会出现 不满的情况。
           --我应该最死循环, 知道数组中的数量 符合他的 % 分数。
          
           if  findItem vertes_count__  random_count ==0 then
          (
           ---因为我没有循环点。所以不用加入 undefined 机制。 在询问面 返回点的函数时,有时面本来是多了,但是在循环面找点是 就是
           ---undefined  这个自己一定要记住。
           append vertes_count__ random_count
          )---end if finditem
          
          )---end for total
          if (vertes_count__.count ==percentage_count ) then
          (
           true_tt=false
          )
         
            )---end while
      
         )----end back

        
        )--end if percentage

       
       
       polyop.setFaceSelection   input_poly  vertes_count__
       
       
      )


      )--- end  case of

     
     )----end fn


    ---上面的元素基本是完成了。但是我是想找到基于poly的因素的操作。因素里面我就想是基于百分比进行操作。


     try(cui.UnRegisterDialogBar gt_random_select)catch()-----这个是法则。
    try (DestroyDialog gt_random_select )catch()
     
    rollout gt_random_select "随机的因素选择" 160 height:133
    (
     spinner random_num_spn "随机数:" pos:[19,3] 109 height:16  range:[0,100000000,0] type:#integer
     spinner random_percentage_spn "随机%:" pos:[19,24] 110 height:16 range:[0,100,0] type:#integer
     button vertex_random_btn "点随机选择" pos:[31,47] 80 height:18
     button edge_random_btn "边随机选择" pos:[31,70] 80 height:18
     button face_random_btn "面随机选择" pos:[31,93] 80 height:18
     fn random_m =
     (
      if random_num_spn .value==0 and random_percentage_spn.value ==0 then
      (
       messagebox "随机数和随机% 数,不能同时为零。也不能同时不为零。"title:"永超编写"
      )---end if
      if random_num_spn .value!=0 and random_percentage_spn.value !=0 then
      (
       messagebox "随机数和随机% 数,不能同时为零。也不能同时不为零。"title:"永超编写"
      )---end if
      
     )
     on vertex_random_btn pressed do
     (
      random_m()
      poly_random_type $ "vertex" random_num_spn .value   random_percentage_spn.value
      
     )---end on
      on edge_random_btn pressed do
     (
      random_m()
      poly_random_type $ "edge" random_num_spn .value   random_percentage_spn.value
      
     )---end on
       on face_random_btn pressed do
     (
      random_m()
      poly_random_type $ "polygon" random_num_spn .value   random_percentage_spn.value
      
     )---end on
     
     
     
    )

     try(cui.UnRegisterDialogBar gt_mode_tatul)catch()-----这个是法则。
    ---************************************
     try (closerolloutfloater gt_mode_tatul ) catch ()
      gt_mode_tatul = newrolloutfloater  "2011.4左右(建模)"  160 800   1000 0  --- 这里的构成方式。
       addrollout  gt_mode_big  gt_mode_tatul
        addrollout  transPivot    gt_mode_tatul
        addrollout  gt_up_down_select    gt_mode_tatul
              addrollout  gt_element__    gt_mode_tatul
                addrollout  gt_random_select    gt_mode_tatul

      --createdialog gt_mode_tatul ---这里我加如就是生产 明白?????

    cui.RegisterDialogBar gt_mode_tatul style:#(#cui_dock_left,#cui_dock_right, #cui_floatable)
    cui.DockDialogBar gt_mode_tatul #cui_dock_right

  • 相关阅读:
    背包问题
    floyed算法
    读Windows编程
    PB串口编程资料(转)
    读TCP-IP详解卷1:协议(1)
    Oracle把两个空格以上的空格,替换为两个空格
    PB中multieditline空间的“~r~n"转"~n"
    PB中掉用Run以后,等Run的程序关闭以后才会执行后边的语句
    一个关于生成随机数的算法
    英语词根
  • 原文地址:https://www.cnblogs.com/gaitian00/p/2025732.html
Copyright © 2011-2022 走看看