creating and saving toolbar
Hi Guys
i have two function first one creates manu group and it works fine
i have two function first one creates manu group and it works fine
[code]
(defun createToolbarGroup (tgname toolbarlist / fn flag) ;(createToolbarGroup "DanielJaros" '("Toolbar1" "Toolbar2"))
(setq flag nil)
(if (not (findfile (strcat tgname ".mns")))
(progn
(setq fn (open (strcat main_cad_folder tgname ".mns") "w"))
(close fn)
)
)
(vlax-for n (vla-get-menuGroups (vlax-get-acad-object))
(if (= (vla-get-name n) tgname)
(setq flag T)
)
(terpri)
(princ (vla-get-name n))
)
(if (null flag)
(vla-load (vla-get-menuGroups (vlax-get-acad-object)) (strcat tgname ".mns"))
)
(foreach tb toolbarlist
(vla-add (vla-get-toolbars (vla-item (vla-get-menuGroups (vlax-get-acad-object)) tgname)) tb)
)
)[/code] and second adds toolbars and buttons (or adds buttons to existing toolbar)
[code]
(defun AddButtons (tgname button_lst / Toolbar newToolbarButton) ; tgname - toolbar group name button_lst - list of buttons
(setq Toolbar nil)
(vlax-for n (vla-get-toolbars (vla-item (vla-get-menuGroups (vlax-get-acad-object)) tgname))
(if (= (vla-get-name n) (car button_lst))
(setq Toolbar n)
)
)
(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
(foreach button (nth 1 button_lst)
(progn
(print (nth 0 button))
(setq newToolbarButton
(vla-addToolbarButton
Toolbar
(1+ (vla-get-count Toolbar))
(nth 0 button) (nth 0 button) (nth 1 button) ; name and command
)
)
(setq SmallBitmapName (nth 2 button)) ; path to icon
(setq LargeBitmapName (nth 2 button))
(vla-setBitmaps newToolbarButton SmallBitmapName LargeBitmapName)
(vla-put-helpString newToolbarButton (nth 3 button)) ; help
)
)
(vla-save (vla-item (vla-get-menuGroups (vlax-get-acad-object)) tgname) acMenuFileCompiled)
(vla-save (vla-item (vla-get-menuGroups (vlax-get-acad-object)) tgname) acMenuFileSource)
)
[/code]
which works almost fine, two last lines:
(vla-save (vla-item (vla-get-menuGroups (vlax-get-acad-object)) tgname) acMenuFileCompiled)
(vla-save (vla-item (vla-get-menuGroups (vlax-get-acad-object)) tgname) acMenuFileSource)
returns error
; error : Automation Error 80020009; [IAcadMenuGroup] Error accessing [SAVE] method. ErrIndex=0;
i have no idea why?
any clue?
0
Comments
-
Seems to be an issue with SAVE function of IAcadMenuGroup ...
please send us a SupportRequest, so we can investigate and fix.
Would be nice if you can provide a bit "fool-proof" (simplified) test code,
which makes it easier for us to reproduce + fix.
Many greetings !0 -
I will try provide demo routine in couple daysIs there any other possibility to save this settings by lisp routine (for example with command method) if not please give me a hint how to save it manually0
-
This may be of interest (from the AC documentation):
Save Method: Saves a document or group of layer property settings; no longer supported for menu groups.0 -
which in my opinion means that it has to be any other method to save this settingscan anyone give my any clue how to save it, with any method usin lisp routineat the moment the only way i see is create those toolbar open "customize", change something in settings and close it0
-
@ Daniel:
If I test your functions there is no error. But (vla-save) is a dummy function in this case. Which would be compatible with AC.
[code](vla-save (vla-item (vla-get-menugroups (vlax-get-acad-object)) "bricscad") acmenufilecompiled) => nil
(vla-save (vla-item (vla-get-menugroups (vlax-get-acad-object)) "bricscad") acmenufilesource) => nil[/code]
Question: Why don't you create an additional menu file 'manually' and just use (vla-load)?0
This discussion has been closed.