Author Topic: How to create a toolbar from scratch (not trough CUI)  (Read 5323 times)

0 Members and 1 Guest are viewing this topic.

Aerdvark

  • Guest
How to create a toolbar from scratch (not trough CUI)
« on: September 07, 2009, 08:08:26 AM »
Is it possible to make a toolbar (with bitmaps, buttons, fly out buttons etc.) but other then through the CUI?

This is what I am thinking of: 1 folder in wich I store the needed bitmaps, and a kind of .mnu file or so, and what else might be needed.

The advantage by doing it this is that I can develope it myself, even at home, and then install it to multiple PC's at the office.

Or am I getting it wrong? That a toolbar must be made through the CUI and when finished export it to a specific file or so?

I'd be glad with some links or so, for I can't find what I need.

Thanks in advance.

Sorry btw for the poor english, I'm just Dutch... :ugly:

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: How to create a toolbar from scratch (not trough CUI)
« Reply #1 on: September 07, 2009, 08:39:01 AM »
You can get quite a lot of information from the toolbars - tbh I haven't tried creating one from scratch, but I wrote this a while back to retrieve the macros associated with a toolbar:

Code: [Select]
;; Get Macros by Lee McDonnell

(defun GetMac (tNme / lst)
  (vl-load-com)
  (vlax-for Men (vla-get-MenuGroups
                  (vlax-get-acad-object))
    (vlax-for tObj (vla-get-Toolbars Men)
      (if (eq tNme (vla-get-Name tObj))
        (vlax-for bObj tObj
          (setq lst (cons (vla-get-Macro bObj) lst))))))
  (vl-remove "" (reverse lst)))

(defun c:test ()
  (princ
    (vl-princ-to-string
      (GetMac "Object Snap")))
  (princ))



Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: How to create a toolbar from scratch (not trough CUI)
« Reply #2 on: September 07, 2009, 08:41:49 AM »
Oh, and you can use vla-add on the Toolbars Collection  :wink:

And then maybe use: vla-addToolbarButton, or vla-addSeparator

Aerdvark

  • Guest
Re: How to create a toolbar from scratch (not trough CUI)
« Reply #3 on: September 07, 2009, 09:17:52 AM »
Hi Lee,

Thanks for the reply.

I know you mean good, but I do not get it, I mean, to what you are pointing me to.

There must be a way to create a toolbar without the CUI interference.
I remember having downloaded a zip file once, unpacked in a specific folder and then loaded it.
But I have no clue where I got it from...

Cheers (as you allways say),
Marco.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: How to create a toolbar from scratch (not trough CUI)
« Reply #4 on: September 07, 2009, 09:29:42 AM »
I have shown you how to get at the Toolbars Collection for each Menu Group - from this you can add a new toolbar and add buttons and separators, or maybe load an existing toolbar.

You can delve further when adding buttons and set Bitmaps for these buttons, for example, here is a dump of a toolbar button:

Code: [Select]
; IAcadToolbarItem: A single button item on an AutoCAD toolbar
; Property values:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 017891b4>
;   CommandDisplayName = "COPYM"
;   Flyout (RO) = AutoCAD: The toolbar item is not a flyout button
;   HelpString = "Copies objects multiple times with options to repeat, divide, measure, and array"
;   Index (RO) = 10
;   Macro = "\003\003copym "
;   Name = "Multiple Copy"
;   Parent (RO) = #<VLA-OBJECT IAcadToolbar 0e872668>
;   TagString = "ID_ACETCOPYM"
;   Type (RO) = 0
; Methods supported:
;   AttachToolbarToFlyout (2)
;   Delete ()
[color=red];   GetBitmaps (2)
;   SetBitmaps (2)[/color]

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: How to create a toolbar from scratch (not trough CUI)
« Reply #5 on: September 07, 2009, 09:32:28 AM »
this should get you started:
Code: [Select]
(vla-add (vla-get-toolbars (vla-item (vla-get-menugroups (vlax-get-acad-object)) "ACAD")) "Toolbar Name")
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Aerdvark

  • Guest
Re: How to create a toolbar from scratch (not trough CUI)
« Reply #6 on: September 07, 2009, 09:59:05 AM »
@ alanjt: the code works! Before I go further how do I delete it for through the CUI the toolbar "Toolbar Name" can't be removed.
I have to learn, that is obvious! Edit: it is deleted now but  don't have a clue what I have done.

@ Lee: I am sorry but I can't follow it. My lack...

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: How to create a toolbar from scratch (not trough CUI)
« Reply #7 on: September 07, 2009, 10:17:54 AM »
@ Lee: I am sorry but I can't follow it. My lack...

Alan has shown you how to use the vla-add function, as I described in my earlier post. You can then add buttons and separators to this newly created vla-object, by using the methods I describe above.

Perhaps perform a dump of the new object, using vlax-dump-object to see what properties and methods are available to you.  :-)

After adding buttons, you can customise these buttons individually, by using the various methods and properties that apply to them.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: How to create a toolbar from scratch (not trough CUI)
« Reply #8 on: September 07, 2009, 11:30:19 AM »
@ alanjt: the code works! Before I go further how do I delete it for through the CUI the toolbar "Toolbar Name" can't be removed.
I have to learn, that is obvious! Edit: it is deleted now but  don't have a clue what I have done.

@ Lee: I am sorry but I can't follow it. My lack...

sorry for the delay:
Code: [Select]
(vla-delete (vla-item (vla-get-toolbars (vla-item (vla-get-menugroups (vlax-get-acad-object)) "ACAD")) "Toolbar Name"))
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Aerdvark

  • Guest
Re: How to create a toolbar from scratch (not trough CUI)
« Reply #9 on: September 08, 2009, 07:24:51 AM »
Delay? No probs  :-)

This is what I was looking for:

Code: [Select]
***TOOLBARS
**TOOLS1
TAG1 [Toolbar ("tbarname", orient, visible, xval, yval, rows)]
TAG2 [Button ("btnname", id_small, id_large)]macro
TAG3 [Flyout ("flyname", id_small, id_large, icon, alias)]macro
TAG4 [Control (element)]

I am allready working with it, so that means that I got where I wanted to be.

Ofcourse it will go wrong and I will come to ask for help but for now I'm glad to have found this.

I attached a menu tutorial for other interested people.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: How to create a toolbar from scratch (not trough CUI)
« Reply #10 on: August 31, 2012, 02:06:48 AM »
Hi!

Yes I know it a old thread but I have a simple question...
I didn´t find how can I display screen menu  ?

Quote
Create Screen Menus
The screen menu section of the MNU file controls the screen menu area.
By default, the screen menu is disabled. To enable the screen menu, click
Display Screen Menu on the Display tab in the Options dialog box.
In the MNU file, the ***SCREEN section label represents the beginning of the
AutoCAD screen menus. The submenu section label shown here is identified
by the string **S. A simple, concise name, such as this, is convenient when
many separate items reference this submenu, as shown in the following
example:

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: How to create a toolbar from scratch (not trough CUI)
« Reply #11 on: August 31, 2012, 02:40:06 AM »
Look at the ScreenMenu system variable: 0=off, 1=on. So you can use setvar to change that.

There's one problem though (at least since 2012, don't know from when this happened) ... the CUI does not show a Screen Menu section. So if you want to edit it, you'll need to modify a CUI in an older ACad. And the ActiveX object only has methods for working with toolbars and pop-up menus.

Another alternative would be to create an old MNU file in Notepad and load it through the menugroups object.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: How to create a toolbar from scratch (not trough CUI)
« Reply #12 on: August 31, 2012, 03:00:03 AM »
Thanks for intressting link irneb.
Maybe I´m blind I don´t get it where have Autocad a sysvar screenmenu to can on/off
Is it right?

Or I understand it not correctly, I load mnu-file looks like this
Code: [Select]
//
//      AutoCAD menu file -
//

***SCREEN
**S
[AutoCAD ]^C^C^P(ai_rootmenus) ^P
[* * * * ]$S=ACAD.OSNAP
[FILE    ]$S=ACAD.01_FILE
[EDIT    ]$S=ACAD.02_EDIT
[VIEW 1  ]$S=ACAD.03_VIEW1
[VIEW 2  ]$S=ACAD.04_VIEW2
[INSERT  ]$S=ACAD.05_INSERT
[FORMAT  ]$S=ACAD.06_FORMAT
[TOOLS 1 ]$S=ACAD.07_TOOLS1
[TOOLS 2 ]$S=ACAD.08_TOOLS2
[DRAW 1  ]$S=ACAD.09_DRAW1
[DRAW 2  ]$S=ACAD.10_DRAW2
[DIMNSION]$S=ACAD.11_DIMENSION
[MODIFY1 ]$S=ACAD.12_MODIFY1
[MODIFY2 ]$S=ACAD.13_MODIFY2
[HELP    ]$S=ACAD.14_HELP
[ASSIST ]$S=ACAD.ASSIST
[LAST   ]$S=ACAD.

But nothing happens, what´s wrong?

Regards Dirk

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: How to create a toolbar from scratch (not trough CUI)
« Reply #13 on: August 31, 2012, 04:00:21 AM »
You're correct. It seems that it doesn't overwrite the existing one. You could of course extract the files inside the ACAD.CUIX (it's simply a zip file). Then you can modify the extracted ScreenMenuRoot.cui file (it's simply a XML file). Though you're discouraged from editing CUI(x) files manually and they're not nearly as easy to understand as MNU's (especially since there's no documentation about their structure).

Edit: of course if you really "want" to ... you can get into this using DotNet. It does expose the ScreenMenu & ScreenMenuItem classes. But of course then you can't directly work on them from ALisp - you'll need VB.Net or C#, at least as intermediate to add property get/set functions and/or method wrappers for lisp to call.
« Last Edit: August 31, 2012, 04:04:38 AM by irneb »
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: How to create a toolbar from scratch (not trough CUI)
« Reply #14 on: August 31, 2012, 04:23:39 AM »
You´re great - have much ideas  :-o I thoug I could fresh up my popup menus without to do it in cui-interface. So I read pdf file from Aerdvark and than I do something wrong, because I don´t understand what it means in cit "...display screen menu" Do you know it?