EDA365电子工程师网

标题: 【求解答】帮忙看一段代码 [打印本页]

作者: defir    时间: 2016-4-27 22:55
标题: 【求解答】帮忙看一段代码
本帖最后由 defir 于 2016-4-28 14:00 编辑

看了几个代码想到一个给PIN和VIA添加KEEPOUT的方式。
但是运行右键done操作不能结束命令,会继续执行完while后才能结束,也就是要done三次才能真正结束。
求帮忙改进代码,谢谢!
代码如下:

  1. axlCmdRegister("Create_Keepout" 'Create_Keepout ?cmdType "interactive" ?doneCmd 'Create_Keepout_done ?cancelCmd 'Create_Keepout_Cancel)
  2. defun(Create_Keepout ()
  3.       
  4.       let((mypopup clinedbid polydbid dia)
  5.       axlUIWPrint(nil "Create_Keepout V0.8")
  6.       axlUIWPrint(nil "Written by df")
  7.           notdone = t
  8.           
  9.     mypopup = axlUIPopupDefine(nil
  10.                            (list (list "Done" 'Create_Keepout_done)
  11.                                 (list "Cancel" 'Create_Keepout_Cancel)))
  12.     axlUIPopupSet(mypopup)
  13.         dia=atoi(axlUIPrompt("Enter Diameter" "50")) ;用弹窗的方式获取自定义的直径
  14.         while(notdone
  15.         FirstPin = nil
  16.         SecondPin = nil
  17.         axlClearSelSet()
  18.         axlSetFindFilter(?enabled list("noall" "VIAS" "pins") ?onButtons list("noall" "VIAS" "pins"))
  19.         axlUIWPrint(nil "Please Select First.....")
  20.                 axlSelect()
  21.         FirstPin = car(axlGetSelSet())
  22.         axlClearSelSet()
  23.         axlHighlightObject(FirstPin)
  24.         axlSetFindFilter(?enabled list("noall" "VIAS" "pins") ?onButtons list("noall" "VIAS" "pins"))
  25.         axlUIWPrint(nil "Please Select Second.....")
  26.                 axlSelect()
  27.         SecondPin = car(axlGetSelSet())
  28.         axlClearSelSet()
  29.         axlHighlightObject(SecondPin)
  30.                  if(FirstPin != nil && SecondPin != nil then
  31.                    clinedbid=caar(axlDBCreateLine(list(FirstPin->xy SecondPin->xy),dia,"Etch/top"));Create Cline on the top.
  32.                    polydbid=axlPolyFromDB(clinedbid ?endCapType 'ROUND);Poly
  33.            axlDeleteObject(clinedbid)
  34.                    df_shape=axlDBCreateShape(car(polydbid) t "Route Keepout/all" nil)
  35.                    axlDBAddProp(car(df_shape),  list("ROUTES_ALLOWED"))
  36.                    axlDBAddProp(car(df_shape),  list("VIAS_ALLOWED"))
  37.                    else
  38.                    axlUIWPrint(nil "Please Select via or pin....")
  39.                     );end if
  40.                         axlDehighlightObject(FirstPin)
  41.             axlDehighlightObject(SecondPin)
  42.                         );end while
  43.         ));end defun
  44.        
  45. defun(Create_Keepout_done ()
  46.                 notdone = nil
  47.                 axlFinishEnterFun()
  48.                 axlUIWPrint(nil "- Done -")
  49.           )
  50. defun(Create_Keepout_Cancel ()
  51.                 notdone = nil
  52.                 axlCancelEnterFun()
  53.                 axlUIWPrint(nil "- Cancel -")
  54.      )
复制代码


作者: deargds    时间: 2016-4-28 14:02
一种改法,将axlSelect改为axlSingleSelectPoint,另外在done cancel回调函数中将菜单清除axlUIPopupSet(nil), 另外axlSelect函数已经是多选操作,不需要调用两次。

  1. axlCmdRegister("Create_Keepout" 'Create_Keepout ?cmdType "interactive" ?doneCmd 'Create_Keepout_done ?cancelCmd 'Create_Keepout_Cancel)
  2. defun(Create_Keepout ()
  3.       
  4.       let((mypopup clinedbid polydbid dia)
  5.       axlUIWPrint(nil "Create_Keepout V0.8")
  6.       axlUIWPrint(nil "Written by df")
  7.           notdone = t
  8.           
  9.     mypopup = axlUIPopupDefine(nil
  10.                            (list (list "Done" 'Create_Keepout_done)
  11.                                 (list "Cancel" 'Create_Keepout_Cancel)))
  12.     axlUIPopupSet(mypopup)
  13.         dia=atoi(axlUIPrompt("Enter Diameter" "50")) ;用弹窗的方式获取自定义的直径
  14.         while(notdone
  15.         FirstPin = nil
  16.         SecondPin = nil
  17.         axlClearSelSet()
  18.         axlSetFindFilter(?enabled list("noall" "VIAS" "pins") ?onButtons list("noall" "VIAS" "pins"))
  19.         axlUIWPrint(nil "Please Select First.....")
  20.                 axlSingleSelectPoint();change
  21.         FirstPin = car(axlGetSelSet())
  22.         axlClearSelSet()
  23.         axlHighlightObject(FirstPin)
  24.         axlSetFindFilter(?enabled list("noall" "VIAS" "pins") ?onButtons list("noall" "VIAS" "pins"))
  25.         axlUIWPrint(nil "Please Select Second.....")
  26.                 axlSingleSelectPoint();change
  27.         SecondPin = car(axlGetSelSet())
  28.         axlClearSelSet()
  29.         axlHighlightObject(SecondPin)
  30.                  if(FirstPin != nil && SecondPin != nil then
  31.                    clinedbid=caar(axlDBCreateLine(list(FirstPin->xy SecondPin->xy),dia,"Etch/top"));Create Cline on the top.
  32.                    polydbid=axlPolyFromDB(clinedbid ?endCapType 'ROUND);Poly
  33.            axlDeleteObject(clinedbid)
  34.                    df_shape=axlDBCreateShape(car(polydbid) t "Route Keepout/all" nil)
  35.                    axlDBAddProp(car(df_shape),  list("ROUTES_ALLOWED"))
  36.                    axlDBAddProp(car(df_shape),  list("VIAS_ALLOWED"))
  37.                    else
  38.                    axlUIWPrint(nil "Please Select via or pin....")
  39.                     );end if
  40.                         axlDehighlightObject(FirstPin)
  41.             axlDehighlightObject(SecondPin)
  42.                         );end while
  43.         ));end defun
  44.        
  45. defun(Create_Keepout_done ()
  46.                 notdone = nil
  47.                 axlFinishEnterFun()
  48.                                 axlUIPopupSet(nil);change
  49.                 axlUIWPrint(nil "- Done -")
  50.           )
  51. defun(Create_Keepout_Cancel ()
  52.                 notdone = nil
  53.                 axlCancelEnterFun()
  54.                                 axlUIPopupSet(nil);change
  55.                 axlUIWPrint(nil "- Cancel -")
  56.      )
复制代码




作者: defir    时间: 2016-4-28 19:14
deargds 发表于 2016-4-28 14:02
一种改法,将axlSelect改为axlSingleSelectPoint,另外在done cancel回调函数中将菜单清除axlUIPopupSet(nil ...

感谢版主的解答。
之前也用的是的axlSingleSelectPoint,但是发现邮件菜单出不来。现在改了还是这个问题。
[attach]112125[/attach][attach]112126[/attach]

作者: deargds    时间: 2016-4-29 08:56
本帖最后由 deargds 于 2016-4-29 09:56 编辑
defir 发表于 2016-4-28 19:14
感谢版主的解答。
之前也用的是的axlSingleSelectPoint,但是发现邮件菜单出不来。现在改了还是这个问题 ...

把axlUIPopupSet(mypopup)放到while里面就行了


  1. axlCmdRegister("Create_Keepout" 'Create_Keepout ?cmdType "interactive" ?doneCmd 'Create_Keepout_done ?cancelCmd 'Create_Keepout_Cancel)
  2. defun(Create_Keepout ()
  3.       
  4.       let((mypopup clinedbid polydbid dia)
  5.       axlUIWPrint(nil "Create_Keepout V0.8")
  6.       axlUIWPrint(nil "Written by df")
  7.           notdone = t
  8.           
  9.     mypopup = axlUIPopupDefine(nil
  10.                            (list (list "Done" 'Create_Keepout_done)
  11.                                 (list "Cancel" 'Create_Keepout_Cancel)))
  12.    
  13.         dia=atoi(axlUIPrompt("Enter Diameter" "50")) ;用弹窗的方式获取自定义的直径
  14.         while(notdone
  15.                 axlUIPopupSet(mypopup)
  16.         FirstPin = nil
  17.         SecondPin = nil
  18.         axlClearSelSet()
  19.         axlSetFindFilter(?enabled list("noall" "VIAS" "pins") ?onButtons list("noall" "VIAS" "pins"))
  20.         axlUIWPrint(nil "Please Select First.....")
  21.                 axlSingleSelectPoint()
  22.         FirstPin = car(axlGetSelSet())
  23.         axlClearSelSet()
  24.         axlHighlightObject(FirstPin)
  25.         axlSetFindFilter(?enabled list("noall" "VIAS" "pins") ?onButtons list("noall" "VIAS" "pins"))
  26.         axlUIWPrint(nil "Please Select Second.....")
  27.                 axlSingleSelectPoint()
  28.         SecondPin = car(axlGetSelSet())
  29.         axlClearSelSet()
  30.         axlHighlightObject(SecondPin)
  31.                  if(FirstPin != nil && SecondPin != nil then
  32.                    clinedbid=caar(axlDBCreateLine(list(FirstPin->xy SecondPin->xy),dia,"Etch/top"));Create Cline on the top.
  33.                    polydbid=axlPolyFromDB(clinedbid ?endCapType 'ROUND);Poly
  34.            axlDeleteObject(clinedbid)
  35.                    df_shape=axlDBCreateShape(car(polydbid) t "Route Keepout/all" nil)
  36.                    axlDBAddProp(car(df_shape),  list("ROUTES_ALLOWED"))
  37.                    axlDBAddProp(car(df_shape),  list("VIAS_ALLOWED"))
  38.                    else
  39.                    axlUIWPrint(nil "Please Select via or pin....")
  40.                     );end if
  41.                         axlDehighlightObject(FirstPin)
  42.             axlDehighlightObject(SecondPin)
  43.                         );end while
  44.         ));end defun
  45.        
  46. defun(Create_Keepout_done ()
  47.                 notdone = nil
  48.                 axlFinishEnterFun()
  49.                                 axlUIPopupSet(nil)
  50.                 axlUIWPrint(nil "- Done -")
  51.           )
  52. defun(Create_Keepout_Cancel ()
  53.                 notdone = nil
  54.                 axlCancelEnterFun()
  55.                                 axlUIPopupSet(nil)
  56.                 axlUIWPrint(nil "- Cancel -")
  57.      )
复制代码



作者: defir    时间: 2016-4-29 12:08
deargds 发表于 2016-4-29 08:56
把axlUIPopupSet(mypopup)放到while里面就行了

感谢解答!昨晚把这个程序改好了,目前发现的BUG已经修复。感谢版主的支持!

作者: mentorkk    时间: 2016-11-15 03:21
學習一下~~
作者: bingshuihuo    时间: 2018-5-23 10:05
缺少是好帖子




欢迎光临 EDA365电子工程师网 (http://bbs.elecnest.cn/) Powered by Discuz! X3.2