Author Topic: Toolbars are not being saved to menu group  (Read 2020 times)

0 Members and 1 Guest are viewing this topic.

Coder

  • Swamp Rat
  • Posts: 827
Toolbars are not being saved to menu group
« on: July 14, 2013, 03:18:06 PM »
Hello guys .

I have written a simple code to create toolbars , but the problem is that it doesn't save them to the menu group that I have
appended them to , and the position of toolbars is really confusing and I can't locate them in the correct position , for example on the
top of the screen and below the menu bar .

Any thoughts of not to load the code with every start up of Autocad and save them to menu group and the correct location I choose ?

Many thanks in advanced

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Toolbars are not being saved to menu group
« Reply #1 on: July 15, 2013, 12:58:34 AM »
Do you mean you made a Lisp which generates the toolbars? If so, I don't think it updates the CUIx file.

Could you post your code so we can see if anything can be explained?
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Coder

  • Swamp Rat
  • Posts: 827
Re: Toolbars are not being saved to menu group
« Reply #2 on: July 15, 2013, 08:00:07 AM »
Hello irneb .

Here is my code which I collected from this forum and from Afralisp .

Code: [Select]
(defun MakeToolbar (/ acadobj menus grp openmacro newTB newToolbar s l)
  (setq acadobj (vlax-get-acad-object))
  (setq menus (vla-get-menuGroups acadobj))
  (if (setq grp (vla-item menus "ACAD"))
    (progn
      (setq newToolbar (vla-add (vla-get-toolbars grp) "My Menu"))
      (setq openMacro (strcat (chr 3) (chr 3) (chr 95) "Line" (chr 32)))
      (setq newTB
             (vla-addToolbarButton
               newToolbar
               (1+ (vla-get-count newToolbar))
               "Draw"
               "Drafting"
               openMacro
             )
      )
      (setq s "MyImage.bmp")
      (setq l "MyImage.bmp")
      (vla-setBitmaps
        newTB
        s
        l
      )
      (vla-put-helpString newTB "Draw line")
    )
  )
  (princ)
)


Coder

  • Swamp Rat
  • Posts: 827
Re: Toolbars are not being saved to menu group
« Reply #3 on: July 17, 2013, 08:26:19 AM »
Any idea guys ?  :-)

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Toolbars are not being saved to menu group
« Reply #4 on: July 18, 2013, 02:07:09 AM »
Any idea guys ?  :-)
As I said, I don't think making / changing the menu through programming is saved into the CUI. Even note the Save/SaveAs methods of the MenuGroup object states that they "have no effect on MenuGroups". http://entercad.ru/acadauto.en/index.html?page=idh_save.htm

So you're out of luck. The only way your modification will be permanent is to include your modifying code into the CUI(x) itself as a LSP to be loaded. Either that, or modify the CUIx manually and throw away the LSP.

Edit: You might also want to check this: http://forums.autodesk.com/t5/NET/AcadMenuGroup-Menu-group-edit-not-saving/td-p/3094282
So even in DotNet it's not an easy task to change an existing CUI.
« Last Edit: July 18, 2013, 02:11:24 AM by irneb »
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Coder

  • Swamp Rat
  • Posts: 827
Re: Toolbars are not being saved to menu group
« Reply #5 on: July 18, 2013, 08:15:12 AM »
Thank you so much irneb for your kind replies .