Author Topic: creating and saving toolbar  (Read 310 times)

potencjalek

  • Member
  • *
  • Posts: 17
creating and saving toolbar
« on: December 20, 2013, 06:35:55 AM »
Hi Guys
i have two function first one creates manu group and it works fine
  1. (defun createToolbarGroup (tgname toolbarlist / fn flag) ;(createToolbarGroup "DanielJaros" '("Narzędzia" "Aplikacje"))
  2. (setq flag nil)
  3. (if (not (findfile (strcat tgname ".mns")))
  4.         (progn
  5.           (setq fn (open (strcat main_cad_folder tgname ".mns") "w"))
  6.           (close fn)
  7.         )
  8. )
  9. (vlax-for n (vla-get-menuGroups (vlax-get-acad-object))
  10.         (if (= (vla-get-name n) tgname)
  11.           (setq flag T)
  12.         )
  13.         (terpri)
  14.         (princ (vla-get-name n))
  15. )
  16. (if (null flag)
  17.         (vla-load (vla-get-menuGroups (vlax-get-acad-object)) (strcat tgname ".mns"))
  18. )
  19. (foreach tb toolbarlist
  20.         (vla-add (vla-get-toolbars (vla-item (vla-get-menuGroups (vlax-get-acad-object)) tgname)) tb)
  21. )
  22. )
and second adds toolbars and buttons
  1. (defun AddButtons (tgname button_lst / Toolbar newToolbarButton) ; tgname - toolbar group name button_lst - list of buttons
  2. (setq Toolbar nil)
  3. (vlax-for n (vla-get-toolbars (vla-item (vla-get-menuGroups (vlax-get-acad-object)) tgname))
  4.         (if (= (vla-get-name n) (car button_lst))
  5.                 (setq Toolbar n)
  6.         )
  7. )
  8. (if (not Toolbar)(setq Toolbar (vla-add (vla-get-toolbars (vla-item (vla-get-menuGroups (vlax-get-acad-object)) tgname)) (car button_lst)))) ; tworzy nowy toolbar
  9. (foreach button (nth 1 button_lst)
  10.         (progn
  11.                 (print (nth 0 button))
  12.                 (setq newToolbarButton
  13.                         (vla-addToolbarButton
  14.                                 Toolbar
  15.                                 (1+ (vla-get-count Toolbar))
  16.                                 (nth 0 button) (nth 0 button) (nth 1 button)    ; name and command
  17.                         )
  18.                 )
  19.                 (setq SmallBitmapName (nth 2 button))           ; path to icon
  20.                 (setq LargeBitmapName (nth 2 button))  
  21.                 (vla-setBitmaps newToolbarButton SmallBitmapName LargeBitmapName)
  22.                 (vla-put-helpString newToolbarButton (nth 3 button)) ; help
  23.         )
  24. )
  25. )
which also works fine, the problem is that after restart bricscad i cant see created toolbars anymore
should I save it somehow?

owenwengerd

  • Administrator
  • Hero Member
  • *****
  • Posts: 2540
    • Outside The Box
Re: creating and saving toolbar
« Reply #1 on: December 20, 2013, 07:10:43 AM »
Please limit your questions here to OpenDCL questions. There are much better forums for general programming and lisp questions.

potencjalek

  • Member
  • *
  • Posts: 17
Re: creating and saving toolbar
« Reply #2 on: December 20, 2013, 08:16:50 AM »
ok, sorry
i will use it only for odcl