马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 qyming2000 于 2019-3-16 17:16 编辑
下面这个正常
- (defun c:anniu1 (/ listtoolbars bitname1
- bitname2 bitname3 currmenugroup
- index1 index2 index3
- macro1 macro2 macro3
- name1 name2 name3
- newtoolbar newtoolbarbutton1
- newtoolbarbutton2 newtoolbarbutton3
- newtoolbarsel
- )
- (defun listtoolbars (groupname / mgroups mgroup lst)
- (if (not
- (vl-catch-all-error-p
- (setq mgroup
- (vl-catch-all-apply
- 'vla-item
- (list (vla-get-menugroups (vlax-get-acad-object))
- groupname
- )
- )
- )
- )
- )
- (vlax-for tbar (vla-get-toolbars mgroup)
- (setq lst (cons (vla-get-name tbar) lst))
- )
- )
- )
- (setq currmenugroup
- (vla-item (vla-get-menugroups (vlax-get-acad-object))
- 0
- )
- )
- (if (and (= (vl-position "经纬仪" (listtoolbars "acad")) nil)
- (= (vl-position "经纬仪" (listtoolbars "custom")) nil)
- )
- (progn
- (setq newtoolbarsel (vla-get-toolbars currmenugroup))
- (setq newtoolbar (vla-add newtoolbarsel "经纬仪"))
- (setq macro1
- (strcat (chr 3) (chr 3) (chr 95) "zjfy" (chr 32))
- )
- (setq macro2
- (strcat (chr 3) (chr 3) (chr 95) "txbh" (chr 32))
- )
- (setq macro3
- (strcat (chr 3) (chr 3) (chr 95) "jdhz" (chr 32))
- )
- (setq index1 0
- index2 1
- index3 2
- )
- (setq name1 "桩机放样")
- (setq name2 "图形编号")
- (setq name3 "基点绘制")
- (setq newtoolbarbutton1
- (vla-addtoolbarbutton
- newtoolbar index1 name1 name1 macro1)
- )
- (setq newtoolbarbutton2
- (vla-addtoolbarbutton
- newtoolbar index2 name2 name2 macro2)
- )
- (setq newtoolbarbutton3
- (vla-addtoolbarbutton
- newtoolbar index3 name3 name3 macro3)
- )
- (setq bitname1 "c:\\temp\\zhuangji.ico")
- (setq bitname2 "c:\\temp\\zwbh.ico")
- (setq bitname3 "c:\\temp\\hui.ico")
- (vla-setbitmaps newtoolbarbutton1 bitname1 bitname1)
- (vla-setbitmaps newtoolbarbutton2 bitname2 bitname2)
- (vla-setbitmaps newtoolbarbutton3 bitname3 bitname3)
- (vla-put-visible newtoolbar :vlax-true)
- )
- )
- (princ)
- )
这个出错
- (defun c:anniu2 (/ listtoolbars bitname currmenugroup
- index lst name name1
- newtoolbar newtoolbarbutton newtoolbarsel
- macro
- )
- (defun listtoolbars (groupname / mgroups mgroup lst)
- (if (not
- (vl-catch-all-error-p
- (setq mgroup
- (vl-catch-all-apply
- 'vla-item
- (list (vla-get-menugroups (vlax-get-acad-object))
- groupname
- )
- )
- )
- )
- )
- (vlax-for tbar (vla-get-toolbars mgroup)
- (setq lst (cons (vla-get-name tbar) lst))
- )
- )
- )
- (setq currmenugroup
- (vla-item (vla-get-menugroups (vlax-get-acad-object))
- 0
- )
- )
- (if (and (= (vl-position "经纬仪4" (listtoolbars "acad")) nil)
- (= (vl-position "经纬仪4" (listtoolbars "custom")) nil)
- )
- (progn
- (setq newtoolbarsel (vla-get-toolbars currmenugroup))
- (setq newtoolbar (vla-add newtoolbarsel "经纬仪4"))
- (setq lst '(("桩机放样" "zjfy" "c:\\temp\\zhuangji.ico")
- ("图形编号" "txbh" "c:\\temp\\zwbh.ico")
- ("基点绘制" "jdhz" "c:\\temp\\hui.ico")
- )
- )
- (setq index 0)
- (foreach x lst
- (setq name (car x)
- macro (cadr x)
- bitname (caddr x)
- )
- (setq newtoolbarbutton
- (vla-addtoolbarbutton
- newtoolbar
- index
- name
- name
- (strcat (chr 3) (chr 3) (chr 95) macro (chr 95))
- )
- )
- (vla-setbitmaps newtoolbarbutton bitname bitname)
- (setq index (1+ index))
- )
- (vla-put-visible newtoolbar :vlax-true)
- )
- )
- (princ)
- )
第一段代码运行正常,第二段出现问题,知识不够,大神们帮帮忙调试 |