- (defun addToolbars (toolbarname lst / gxl-catchapply bitname toolbars index lst name name1 newtoolbar newtoolbarbutton macro)
- (defun gxl-catchapply (fun args / result)
- (if (not (vl-catch-all-error-p
- (setq result
- (vl-catch-all-apply
- (if (= 'sym (type fun))
- fun
- (function fun)
- )
- args
- )
- )
- )
- )
- result
- )
- )
- (setq toolbars
- (vla-get-toolbars
- (vla-item (vla-get-menugroups (vlax-get-acad-object))
- 0
- )
- )
- )
- (if (setq newtoolbar
- (gxl-catchapply
- vla-item
- (list toolbars toolbarname)
- )
- )
- (vla-delete newtoolbar)
- )
- (setq newtoolbar (vla-add toolbars toolbarname))
- (foreach x lst
- (setq index 0
- name (car x)
- macro (cadr x)
- bitname (caddr x)
- )
- (cond ((= name "--") (vla-addseparator newtoolbar (1+ index)))
- (t
- (setq newtoolbarbutton
- (gxl-catchapply
- vla-addtoolbarbutton
- (list newtoolbar
- index
- name
- name
- (strcat (chr 32) (chr 32) (chr 95) macro (chr 32))
- )
- )
- )
- (gxl-catchapply
- vla-setbitmaps
- (list newtoolbarbutton bitname bitname)
- )
- )
- )
- (setq index (1+ index))
- )
- (vla-put-visible newtoolbar :vlax-true)
- (princ)
- )
- [code]addToolbars "文字工具3"
- '(("文字合并" "wzhb" "wwzhb.ico")
- ("文字对齐" "wzdq" "wwzdq.ico")
- ("--")
- ("文字编号" "wzbh" "wwzbh.ico")
- )
- )
[/code] |