- UID
- 5
- 积分
- 2526
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-3
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
http://fresco.yo2.cn/archives/642094#more-642094
程序思路就是利用ActiveX对像模型提供的方法和属性。
目前的问题:设置条目的图标和快捷键(比如Ctrl+Shift+P)不知如何实现。
源代码:
AddBplotMenu.lsp
- [font=courier new]
- ;; 删除菜单
- (defun C:RemoveBplotMenu (/ MenuBar n i MenuItem Menu tag)
- (setq MenuBar (vla-get-menubar (vlax-get-acad-object)))
- ;; 找菜单“文件(&F)” "&File" tag: ID_MnFile
- (setq n (vla-get-count MenuBar))
- (setq i (1- n))
- (while (and (>= i 0) ; 没有超过上限
- (/= "ID_MnFile" (vla-get-tagstring (setq menuitem (vla-item MenuBar i)))) ; 找到"文件"菜单条
- )
- (setq i (1- i))
- )
- (if (< i 0)
- (setq i 0)
- ) ; 如果没有文件菜单, 取第一条菜单
- (setq menu (vla-item MenuBar i))
- ;;遍历文件菜单 删除原来的批量打印条目
- (setq n (vla-get-count menu))
- (setq i (1- n))
- (while (> i 0)
- (setq menuitem (vla-item menu i))
- (setq tag (vla-get-tagstring menuitem))
- (if (member tag '("ID_mnuBatchPlot" "ID_mnuBatchPlot2" "ID_mnuBatchPlotPopup"))
- (vla-delete menuitem)
- )
- (setq i (1- i))
- )
- (princ)
- )
- ;; 添加菜单
- (defun C:AddBplotMenu (/ MenuBar menu menuitem bplotPopupMenu bplotmenuitem cap tag tmp i n)
- (C:RemoveBplotMenu)
- (setq MenuBar (vla-get-menubar (vlax-get-acad-object)))
- ;; 找到菜单“文件(&F)” "&File" tag: ID_MnFile
- (setq n (vla-get-count MenuBar))
- (setq i (1- n))
- (while (and (>= i 0) ; 没有超过上限
- (/= "ID_MnFile" (vla-get-tagstring (setq menuitem (vla-item MenuBar i)))) ; 找到"文件"菜单条
- )
- (setq i (1- i))
- )
- (if (< i 0) ; 如果没有文件菜单, 取第一条菜单
- (setq i 0)
- )
- (setq menu (vla-item MenuBar i))
- ;; 找到打印菜单项, 设置当前插入位置
- (setq i 0)
- (setq n (vla-get-count menu))
- (while (and (< i n) ; 没有超过上限
- (/= "ID_Print" (vla-get-tagstring (setq menuitem (vla-item menu i)))) ; 找到"打印"菜单条
- )
- (setq i (1+ i))
- )
- (if (= i n) ; 如果没有找到"打印"菜单条, 插在倒数第二条.
- (setq i (- n 2))
- )
- ;; 在当前插入位置的下面一条添加批量打印条目
- (setq bplotmenuitem
- (vla-addmenuitem
- menu
- (setq i (1+ i))
- "批量打印(&B)..."
- "\003\003_BatchPlot "
- )
- )
- (vla-put-label bplotmenuitem "$(if,$(eq,$(getvar,blockeditor),1),~)批量打印(&B)...")
- (vla-put-tagstring bplotmenuitem "ID_mnuBatchPlot")
- (vla-put-helpstring bplotmenuitem "批量打印、批量生成布局、批量分图实用工具程序")
- ;; 再在下面创建下级批量打印实用工具子菜单
- (setq bplotPopupMenu (vla-addsubmenu menu (1+ i) "批量打印实用工具(&L)"))
- ; (vla-put-tagstring bplotPopupMenu "ID_mnuBatchPlotPopup") ;不知道为什么不行.
- ;; 下面这段代码设置批量打印实用工具子菜单的Tag
- (setq n (vla-get-count menu))
- (setq i (1- n))
- (while (> i 0)
- (setq menuitem (vla-item menu i))
- (setq cap (vla-get-caption menuitem))
- (if (= "批量打印实用工具(&L)" cap)
- (vla-put-tagstring menuitem "ID_mnuBatchPlotPopup")
- )
- (setq i (1- i))
- )
- (setq i 0)
-
- ;; 下面是子菜单条目
- (setq tmp
- (vla-addmenuitem
- bplotPopupMenu
- (setq i (1+ i))
- "批量打印(&C)..."
- "\003\003_bp_doPlot "
- )
- )
- (vla-put-label tmp "$(if,$(eq,$(getvar,blockeditor),1),~)批量打印(&C)...")
- (vla-put-helpstring tmp "批量打印图纸,直接发送到物理打印机或虚拟打印机")
- (setq tmp
- (vla-addmenuitem
- bplotPopupMenu
- (setq i (1+ i))
- "批量生成布局(&L)..."
- "\003\003_bp_doLayout "
- )
- )
- (vla-put-label tmp "$(if,$(eq,$(getvar,blockeditor),1),~)批量生成布局(&L)...")
- (vla-put-helpstring tmp "批量按当前的打印设置生成布局,每个图框一个布局")
- (setq tmp
- (vla-addmenuitem
- bplotPopupMenu
- (setq i (1+ i))
- "批量生成PLT文件(&P)..."
- "\003\003_bp_doPlotFile "
- )
- )
- (vla-put-label tmp "$(if,$(eq,$(getvar,blockeditor),1),~)批量生成PLT文件(&P)...")
- (vla-put-helpstring tmp "批量生成PLT打印文件供机房绘图仪服务器统一打印")
- (setq tmp
- (vla-addmenuitem
- bplotPopupMenu
- (setq i (1+ i))
- "批量切分图纸(&W)..."
- "\003\003_bp_doWblock "
- )
- )
- (vla-put-label tmp "$(if,$(eq,$(getvar,blockeditor),1),~)批量切分图纸(&W)...")
- (vla-put-helpstring tmp "自动根据图框切分图纸,每个图框一个DWG文件,供归档用")
- (setq tmp
- (vla-addmenuitem
- bplotPopupMenu
- (setq i (1+ i))
- "打印现有布局(&A)..."
- "\003\003_bp_doPlotLayout "
- )
- )
- (vla-put-label tmp "$(if,$(eq,$(getvar,blockeditor),1),~)打印现有布局(&A)...")
- (vla-put-helpstring tmp "按现有的布局显示顺序批量打印现有的布局空间")
- (vla-AddSeparator
- bplotPopupMenu
- (setq i (1+ i))
- )
- (setq tmp (vla-addmenuitem
- bplotPopupMenu
- (setq i (1+ i))
- "清除批量打印数据(&D)"
- "\003\003_DeleteBPlotData "
- )
- )
- (vla-AddSeparator
- bplotPopupMenu
- (setq i (1+ i))
- )
- (vla-addmenuitem
- bplotPopupMenu
- (setq i (1+ i))
- "捐助作者支持开发(&D)"
- "\003\003_Browser (findfile "donate.htm") "
- )
- (vla-addmenuitem
- bplotPopupMenu
- (setq i (1+ i))
- "访问软件主页(&M)"
- "\003\003_Browser [url]http://fresco.yo2.cn/archives/92111[/url] "
- )
- (vla-addmenuitem
- bplotPopupMenu
- (setq i (1+ i))
- "批量打印帮助(&H)"
- "\003\003_Browser (findfile "bp_help.htm") "
- )
-
- (princ)
- )
- ;; 加载批量打印菜单
- (C:AddBplotMenu)
- (princ)[/font]
|
|