找回密码
 注册
关于网站域名变更的通知
查看: 7214|回复: 53
打印 上一主题 下一主题

【分享源代碼】建立動態選單/添加自定义菜单

  [复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2016-1-25 11:09 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

EDA365欢迎您登录!

您需要 登录 才可以下载或查看,没有帐号?注册

x
本帖最后由 XYX365 于 2016-1-25 13:42 编辑

如何把自己的菜单插入到allegro menu,使用動態選單

;filename:fDynamicMenus.il
;此程式只適用於Allegro v16.3以上
;必須直接加載到allegro.ilinit檔裡面,不能在其他地方載入此程式
;此程式可以設計成中英文語言的選單


; Load: load("fDynamicMenus.il")
;附件程式不包含選單上的任一程式工具



fDynamicMenus.rar (1.71 KB, 下载次数: 49)


  1. ;filename:fDynamicMenus.il
  2. ;此程式只適用於Allegro v16.3以上
  3. ;必須直接加載到allegro.ilinit檔裡面,不能在其他地方載入此程式
  4. ;此程式可以設計成中英文語言的選單

  5. ; Load: load("fDynamicMenus.il")

  6. setShellEnvVar("LANG=ENG") ;強制設定為英文選單
  7. case(getShellEnvVar("LANG")
  8.         ("GB"
  9.                 ;這裡是擺放簡體中文位置,沒有完成,必須自行建立
  10.                 lskillMenu = '(
  11.                         (popup "EDA365 Skill for Test") ;主選單上的名稱
  12.                                 ("Chinese Transfer" "(fnChineseTransform)") ;第一個字串是顯示在選單上,第二個字串是執行命令
  13.                                 ("Quick Open" "filemgr") ;程式選單項目
  14.                                 (separator) ;區格線
  15.                                 ("Netin,3rd Party" "netin3rd_protel")
  16.                                 ("Compare Net_Changes" "gnetrpt")
  17.                                 ("Compare BRD_Changes" "component_changes")
  18.                                 ("Clear Layout TempFile" "tmpdel")
  19.                                 ("Check Height" "heightchk")
  20.                                 ("Hilight TestPoint Net" "hlnpt")
  21.                                 ("Set_drillkey" "setdrill")
  22.                                 ("Set Design Color" "s1")
  23.                                 ("Show Height/width" "draw targets")
  24.                                 ("Add Layer" "addlayer")
  25.                                 ("Calc Trace Width" "twcal")
  26.                                 ("Calc Via Quantity" "viacal")
  27.                                 ("Cut Line" "clinecut")
  28.                                 ("Cut Shape" "cutshape")
  29.                                 ("Check width" "chgew")
  30.                                 ("Etch Cross Check" "ecp")
  31.                                 (popup "Text Function") ;子選單名稱
  32.                                         ("Edit TextBlock" "settxtpw")
  33.                                         ("SilkScreen Export/inport" "text_out_in")
  34.                                         ("Move Text2Center" "r2c")
  35.                                         ("Check_NoRefdes" "ch_noref")
  36.                                         ("Check_refdes_direction" "ch_dir")
  37.                                         ("Check_text_grap" "ch_text_overlap")
  38.                                 (end)
  39.                                 (popup "SplitPlane")
  40.                                         ("SplitPlane_CreateLayers" "SplitPlane_CreateLayers")
  41.                                         ("SplitPlane_CreateShapes" "SplitPlane_CreateShapes")
  42.                                 (end)
  43.                                 (popup "DataBase Check")
  44.                                         ("DataBase &Check..." "dbdoctor")
  45.                                         ("DANGLING CHECK" "dangling")
  46.                                         ("DumpVia CHECK" "check_dvia")
  47.                                 (end)
  48.                                 (popup "TAPEOUT")
  49.                                         ("Artwork..." "artwork")
  50.                                         (separator)
  51.                                         (popup "AUTO DRILL")
  52.                                                 ("SET NCcustom" "setnccus")
  53.                                                 ("Drill Legend" "nclegend")
  54.                                                 ("Drill Route" "ncdr")
  55.                                         (end)
  56.                                         ("Setting FilmControl" "efilm")
  57.                                         ("Auto CreateArtWork" "ns_gerber")
  58.                                         ("Output GFile" "outfilm")
  59.                                         ("draw pin hole" "draw pin hole")
  60.                                         ("Ouput DXF/RefPdf/IPC356" "odxf")
  61.                                         ("Ouput SymLoc" "inform")
  62.                                         (popup "Sort Output File")
  63.                                                 ("Move Gfile" "sortgfile")
  64.                                                 ("Zip Gerber" "gzip")
  65.                                         (end)
  66.                                 (end)
  67.                                 ("Export CAD" "cadout")
  68.                                 (separator)
  69.                                 (popup "[ System Tools ]")
  70.                                         ("[ Snap Screen ]" "system snippingtool")
  71.                                         ("[ Run Notepad ]" "system notepad")
  72.                                         ("[ Run Calculator ]" "system calc")
  73.                                         ("[ Run Paint ]" "system mspaint")
  74.                                         ("[ Run CMD ]" "system")
  75.                                 (end)
  76.                 (end)
  77.                 )
  78.         )
  79.         ("BIG5"
  80.                 ;這裡是擺放繁體中文位置,沒有完成,必須自行建立
  81.                 lSkillMenu = '(
  82.                         (popup "EDA365 Skill for Test") ;主選單上的名稱
  83.                                 ;第一個字串是顯示在選單上,第二個字串是執行命令
  84.                                 ("\244\244\244\345" "(fnChineseTransform)") ;中文碼轉八進位的ASCII碼
  85.                                 ("Quick Open" "filemgr") ;程式選單項目
  86.                                 (separator) ;區格線
  87.                                 ("Netin,3rd Party" "netin3rd_protel")
  88.                                 ("Compare Net_Changes" "gnetrpt")
  89.                                 ("Compare BRD_Changes" "component_changes")
  90.                                 ("Clear Layout TempFile" "tmpdel")
  91.                                 ("Check Height" "heightchk")
  92.                                 ("Hilight TestPoint Net" "hlnpt")
  93.                                 ("Set_drillkey" "setdrill")
  94.                                 ("Set Design Color" "s1")
  95.                                 ("Show Height/width" "draw targets")
  96.                                 ("Add Layer" "addlayer")
  97.                                 ("Calc Trace Width" "twcal")
  98.                                 ("Calc Via Quantity" "viacal")
  99.                                 ("Cut Line" "clinecut")
  100.                                 ("Cut Shape" "cutshape")
  101.                                 ("Check width" "chgew")
  102.                                 ("Etch Cross Check" "ecp")
  103.                                 (popup "Text Function") ;子選單名稱
  104.                                         ("Edit TextBlock" "settxtpw")
  105.                                         ("SilkScreen Export/inport" "text_out_in")
  106.                                         ("Move Text2Center" "r2c")
  107.                                         ("Check_NoRefdes" "ch_noref")
  108.                                         ("Check_refdes_direction" "ch_dir")
  109.                                         ("Check_text_grap" "ch_text_overlap")
  110.                                 (end)
  111.                                 (popup "SplitPlane")
  112.                                         ("SplitPlane_CreateLayers" "SplitPlane_CreateLayers")
  113.                                         ("SplitPlane_CreateShapes" "SplitPlane_CreateShapes")
  114.                                 (end)
  115.                                 (popup "DataBase Check")
  116.                                         ("DataBase &Check..." "dbdoctor")
  117.                                         ("DANGLING CHECK" "dangling")
  118.                                         ("DumpVia CHECK" "check_dvia")
  119.                                 (end)
  120.                                 (popup "TAPEOUT")
  121.                                         ("Artwork..." "artwork")
  122.                                         (separator)
  123.                                         (popup "AUTO DRILL")
  124.                                                 ("SET NCcustom" "setnccus")
  125.                                                 ("Drill Legend" "nclegend")
  126.                                                 ("Drill Route" "ncdr")
  127.                                         (end)
  128.                                         ("Setting FilmControl" "efilm")
  129.                                         ("Auto CreateArtWork" "ns_gerber")
  130.                                         ("Output GFile" "outfilm")
  131.                                         ("draw pin hole" "draw pin hole")
  132.                                         ("Ouput DXF/RefPdf/IPC356" "odxf")
  133.                                         ("Ouput SymLoc" "inform")
  134.                                         (popup "Sort Output File")
  135.                                                 ("Move Gfile" "sortgfile")
  136.                                                 ("Zip Gerber" "gzip")
  137.                                         (end)
  138.                                 (end)
  139.                                 ("Export CAD" "cadout")
  140.                                 (separator)
  141.                                 (popup "[ System Tools ]")
  142.                                         ("[ Snap Screen ]" "system snippingtool")
  143.                                         ("[ Run Notepad ]" "system notepad")
  144.                                         ("[ Run Calculator ]" "system calc")
  145.                                         ("[ Run Paint ]" "system mspaint")
  146.                                         ("[ Run CMD ]" "system")
  147.                                 (end)
  148.                 (end)
  149.                 )
  150.         )
  151.         (t
  152.                 ;這裡是擺放英文位置
  153.                 lSkillMenu = '(
  154.                         (popup "EDA365 Skill for Test") ;主選單上的名稱
  155.                                 ("Chinese Transfer" "(fnChineseTransform)") ;第一個字串是顯示在選單上,第二個字串是執行命令
  156.                                 ("Quick Open" "filemgr") ;程式選單項目
  157.                                 (separator) ;區格線
  158.                                 ("Netin,3rd Party" "netin3rd_protel")
  159.                                 ("Compare Net_Changes" "gnetrpt")
  160.                                 ("Compare BRD_Changes" "component_changes")
  161.                                 ("Clear Layout TempFile" "tmpdel")
  162.                                 ("Check Height" "heightchk")
  163.                                 ("Hilight TestPoint Net" "hlnpt")
  164.                                 ("Set_drillkey" "setdrill")
  165.                                 ("Set Design Color" "s1")
  166.                                 ("Show Height/width" "draw targets")
  167.                                 ("Add Layer" "addlayer")
  168.                                 ("Calc Trace Width" "twcal")
  169.                                 ("Calc Via Quantity" "viacal")
  170.                                 ("Cut Line" "clinecut")
  171.                                 ("Cut Shape" "cutshape")
  172.                                 ("Check width" "chgew")
  173.                                 ("Etch Cross Check" "ecp")
  174.                                 (popup "Text Function") ;子選單名稱
  175.                                         ("Edit TextBlock" "settxtpw")
  176.                                         ("SilkScreen Export/inport" "text_out_in")
  177.                                         ("Move Text2Center" "r2c")
  178.                                         ("Check_NoRefdes" "ch_noref")
  179.                                         ("Check_refdes_direction" "ch_dir")
  180.                                         ("Check_text_grap" "ch_text_overlap")
  181.                                 (end)
  182.                                 (popup "SplitPlane")
  183.                                         ("SplitPlane_CreateLayers" "SplitPlane_CreateLayers")
  184.                                         ("SplitPlane_CreateShapes" "SplitPlane_CreateShapes")
  185.                                 (end)
  186.                                 (popup "DataBase Check")
  187.                                         ("DataBase &Check..." "dbdoctor")
  188.                                         ("DANGLING CHECK" "dangling")
  189.                                         ("DumpVia CHECK" "check_dvia")
  190.                                 (end)
  191.                                 (popup "TAPEOUT")
  192.                                         ("Artwork..." "artwork")
  193.                                         (separator)
  194.                                         (popup "AUTO DRILL")
  195.                                                 ("SET NCcustom" "setnccus")
  196.                                                 ("Drill Legend" "nclegend")
  197.                                                 ("Drill Route" "ncdr")
  198.                                         (end)
  199.                                         ("Setting FilmControl" "efilm")
  200.                                         ("Auto CreateArtWork" "ns_gerber")
  201.                                         ("Output GFile" "outfilm")
  202.                                         ("draw pin hole" "draw pin hole")
  203.                                         ("Ouput DXF/RefPdf/IPC356" "odxf")
  204.                                         ("Ouput SymLoc" "inform")
  205.                                         (popup "Sort Output File")
  206.                                                 ("Move Gfile" "sortgfile")
  207.                                                 ("Zip Gerber" "gzip")
  208.                                         (end)
  209.                                 (end)
  210.                                 ("Export CAD" "cadout")
  211.                                 (separator)
  212.                                 (popup "[ System Tools ]")
  213.                                         ("[ Snap Screen ]" "system snippingtool")
  214.                                         ("[ Run Notepad ]" "system notepad")
  215.                                         ("[ Run Calculator ]" "system calc")
  216.                                         ("[ Run Paint ]" "system mspaint")
  217.                                         ("[ Run CMD ]" "system")
  218.                                 (end)
  219.                 (end)
  220.                 )
  221.         )
  222. )
  223. procedure(fnDynamicMenusTrig(tMenuFile)
  224.         let((xMenuID)
  225.                 when(tMenuFile == "allegro" ;只判斷第一次載入及執行,如果沒有此判斷的話,有其他程式也是使用動態選單時,就會再加載一次
  226.                         xMenuID = axlUIMenuFind(nil -1)
  227.                         axlUIMenuInsert(xMenuID lSkillMenu)
  228.                 )
  229.         )
  230. )
  231. procedure(fnChineseTransform() ;中文碼轉八進位的ASCII碼函數
  232.         axlUIPrompt("Code:",sprintf(nil,"%L",axlUIPrompt("Please Input Chinese:")))
  233. )
  234. ; Using the trigger function directly
  235. axlTriggerSet('menu  'fnDynamicMenusTrig)
复制代码



该用户从未签到

推荐
 楼主| 发表于 2016-1-28 18:47 | 只看该作者
361553894 发表于 2016-1-28 13:14
15版本的菜单插入就不提供了

再確認一下,你的程式功能,
1.在Allegro.ilinit裡面加載 SkillMenu.il
2.開啟Allegro.exe
3.執行sm
4.這時候就加載你所設定的Menu(m1~m7),之後會重覆加載好幾次

這是因為下面的判斷問題
when(g_SkillMenuTimerNum>1
        if(isCallable('axlUIMenuFind) then
                if(axlUIMenuFind(nil,"wxGrids") then
                        axlUIWTimerRemove(g_SkillMenuTimerId)
                        g_SkillMenuTimerId='unbound
                        g_SkillMenuTimerNum='unbound
                        return(t);
                );if
        );if
);when


你的程式工作流程應該是這樣
1.執行sm後,
2.執行下列
     g_SkillMenuTimerId=nil
     g_SkillMenuTimerNum=0
     g_SkillMenuTimerId=axlUIWTimerAdd(nil,2000,nil,'wxSkillMenu_TimerCallBack)

3.時間等待2000後再執行wxSkillMenu()函數,
4.這時候就執行下面並執行好幾次
when(g_SkillMenuTimerNum>1
        if(isCallable('axlUIMenuFind) then
                if(axlUIMenuFind(nil,"wxGrids") then
                        axlUIWTimerRemove(g_SkillMenuTimerId)
                        g_SkillMenuTimerId='unbound
                        g_SkillMenuTimerNum='unbound
                        return(t);
                );if
        );if
);when


如果你只要加載一次的話,你修改成下面試試看,只留紅字部分
       if(boundp('g_SkillMenuTimerId) && boundp('g_SkillMenuTimerNum) then
                ;if(g_SkillMenuTimerNum>5 then
                ;        axlUIWTimerRemove(g_SkillMenuTimerId)
                ;        g_SkillMenuTimerId='unbound
                ;        g_SkillMenuTimerNum='unbound
                ;else
                ;        g_SkillMenuTimerNum++
                ;);if
                ;when(g_SkillMenuTimerNum>1
                ;        if(isCallable('axlUIMenuFind) then
                ;                if(axlUIMenuFind(nil,"wxGrids") then
                                        axlUIWTimerRemove(g_SkillMenuTimerId)
                                                g_SkillMenuTimerId='unbound
                                        g_SkillMenuTimerNum='unbound
                                        return(t);
                ;                );if
                ;        );if
                ;);when
        else

                g_SkillMenuTimerId=nil
                g_SkillMenuTimerNum=0
                g_SkillMenuTimerId=axlUIWTimerAdd(nil,2000,nil,'wxSkillMenu_TimerCallBack)
        );if

点评

试过了,加载不上,不知道哪个函数把加载上的菜单又清空了 估计他某个启动执行的函数有 axlUIMenuLoad(nil)这个指令  详情 回复 发表于 2016-1-29 09:01

该用户从未签到

推荐
发表于 2016-1-29 09:19 | 只看该作者
XYX365 发表于 2016-1-28 19:02
其實不用加入你貼的程式,也可以加載一次,就不會重覆好幾次,我猜原始作者應該有遇到過加載第一次失敗的問 ...

Skill > axlTriggerPrint
E- *Error* skillDev not enabled.
E-
ERROR
Skill > axlTriggerPrint()
E- *Error* skillDev not enabled.
E-
ERROR
Skill >
这个是什么原因呢?

点评

問題是你使用破解的Allegro.exe的原因  详情 回复 发表于 2016-1-29 09:22

该用户从未签到

推荐
发表于 2016-1-29 08:41 | 只看该作者
XYX365 发表于 2016-1-28 19:02
其實不用加入你貼的程式,也可以加載一次,就不會重覆好幾次,我猜原始作者應該有遇到過加載第一次失敗的問 ...

我之前有试过,只加载一次,发现会被刷掉,估计他其他的函数跟菜单加载有冲突
他这个目的是不是隔两秒检查一次菜单有没有存在,如果存在就跳出,否则就重新加载

点评

你是不是有加載EDA365 skill?  详情 回复 发表于 2016-1-29 09:06

该用户从未签到

40#
发表于 2021-12-16 16:23 | 只看该作者
学习一下如何加载菜单
  • TA的每日心情
    开心
    2025-6-11 15:53
  • 签到天数: 19 天

    [LV.4]偶尔看看III

    39#
    发表于 2021-6-16 16:10 | 只看该作者
    请问这个怎么切换到中文呢?

    该用户从未签到

    38#
    发表于 2021-2-2 11:42 | 只看该作者
    XYX365 发表于 2016-1-29 09:06
    你是不是有加載EDA365 skill?

    这个和EDA365 Skill 在一起就冲突 就会出现重复菜单有什么好的解决的办法么
  • TA的每日心情
    开心
    2025-11-14 15:41
  • 签到天数: 543 天

    [LV.9]以坛为家II

    37#
    发表于 2020-11-26 17:33 | 只看该作者
    感谢分享,学习了

    该用户从未签到

    36#
    发表于 2019-3-13 16:22 | 只看该作者
    博大精深 给力的很
  • TA的每日心情
    开心
    2019-11-19 15:59
  • 签到天数: 1 天

    [LV.1]初来乍到

    35#
    发表于 2017-8-28 16:14 | 只看该作者
    太难了,看不懂 如有 有大神录视频就好了

    该用户从未签到

    33#
    发表于 2016-11-13 13:47 | 只看该作者
    謝謝樓主分享

    该用户从未签到

    31#
    发表于 2016-2-22 14:08 | 只看该作者
    非常不错,download 学习下
  • TA的每日心情
    开心
    2024-8-22 15:58
  • 签到天数: 22 天

    [LV.4]偶尔看看III

    30#
    发表于 2016-2-19 16:09 | 只看该作者
    謝謝大大的分享,
    学习一下!

    该用户从未签到

    28#
     楼主| 发表于 2016-2-19 11:17 | 只看该作者
    shihongjing 发表于 2016-2-19 10:00
    请问一下怎么才能让菜单出来,我加载了没有反应,command里显示 loading axlcore.cxt    t

    你直接將此行 load("fDynamicMenus.il") 加入到allegro.ilinit,然後開啟allegro.exe就會自動加載

    该用户从未签到

    27#
    发表于 2016-2-19 10:00 | 只看该作者
    请问一下怎么才能让菜单出来,我加载了没有反应,command里显示 loading axlcore.cxt    t

    点评

    你直接將此行 load("fDynamicMenus.il") 加入到allegro.ilinit,然後開啟allegro.exe就會自動加載  详情 回复 发表于 2016-2-19 11:17
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    关闭

    推荐内容上一条 /1 下一条

    EDA365公众号

    关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

    GMT+8, 2025-11-22 14:25 , Processed in 0.203125 second(s), 31 queries , Gzip On.

    深圳市墨知创新科技有限公司

    地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

    快速回复 返回顶部 返回列表