To download this complete Tutorial including, all Menu's and Support
files,
be brave and Click Here.
Creating Menu's - Page I.
You can write or, obtain, as many AutoLISP routines as you like, but
it's still a pain in the bum to have to type in something like :
(load "DDStruc_Steel_Ver2")
To have to type this in, or even remember the name every time you need
to load or, run the routine, is just basically daft and un-productive.
You could, load all your routines from the Acad.Lsp file. This though,
would mean that they are all in memory, chewing up your system resources.
What you need to be able to do is to load/run the routines from the
AutoCAD menu. Not so long ago, in earlier releases, the only option you
had was to modify the standard AutoCAD menu. Not anymore. Now you can
create a custom menu known as a "Partial Menu" and install this
to run side by side with the standard AutoCAD menu.
This Tutorial will take you through all the steps of developing a
fully, functional Custom Standard Menu.
Note : I will only be covering Pull Down Menu's, Image Menu's and
Toolbars in this tutorial. If you need information on Screen, Button or
Tablet Menu's, then please refer to the AutoCAD Customization Manual.
To get started let's begin with designing a simple Pull Down or Pop
Menu.
Fire up your text editor and type in the following saving the file as
Test.Mnu :
(Please ensure that you save all files to a directory in the AutoCAD
Search Path.)
***MENUGROUP=TEST //menu name
***POP1 //pull down name
P1-1[Test Menu] //pull down label
P1-2[Line] //menu items preceeded with ID
P1-3[Copy]
P1-4[Move]
P1-5[Zoom]
The first line :
***MENUGROUP=TEST
is the name of the Partial Menu.
The second line :
***POP1
is the name of the Drop Down or POP menu.
The third line consists of 2 parts :
P1-1
This is the "Name Tag" or "ID" of the menu item and
allows you to access the menu item programmatically. The second part :
[Test-Menu]
is the menu label that appears in the Pull Down Menu.
The first label in a pull down menu always defines the menu bar title
whilst, the succeeding labels define menu and sub-menu items.
Now we need to load the menu.
If you already know how to Load and Un-Load menu files you can now load
Test.mnu.
If not, click here for detailed instructions.
A new menu item will appear on the menu bar entitled "Test
Menu".
It should look like this :
O.K. Now we've got our menu to display but, there's a problem. It
doesn't do anything!! Let's make it functional.
Create a new menu file entitled TEST1.MNU and type in the following:
***MENUGROUP=TEST1
***POP1
P1-1[&Test Menu1]
P1-2[&Line]^C^CLine
P1-3[&Copy]^C^CCopy
P1-4[M&ove]^C^CMove
P1-5[&Zoom]^C^CZoom
Load this menu, following the same routine as you did for the first menu.
"Test Menu1" will appear in the menu bar and your new pull down
menu should look like this :
Let's have a close look at one of the menu items :
P1-2[&Line]^C^CLine
The first part, P1-1 is, of course, the menu item ID.
The second part, [&Line] is the menu label. But did you notice
something different? What is the '&' character doing in front of the
'L'?
If you precede any letter in the menu item label with '&', this will
define the letter as the shortcut key to this menu item.
(There are other special label characters but, we will discuss these at a
later stage.) In other words, when you press 'ALT L' the Line Menu Item
will be chosen and any action affiliated to it will be triggered.
Following the item label, each menu item can consist of a command,
parameter,
or a sequence of commands and parameters. Let's look at the Line menu item
macro.
^C^CLine
Just in case we have a previous incomplete command, we use the string
^C^C to start our menu macro. This is exactly the same as pressing CTRL+C
or ESC, twice on the keyboard. We use ^C twice because some AutoCAD
commands need to be cancelled twice before they return to the Command
prompt.
(e.g. The Dim Command.)
We immediately follow this sequence with our AutoCAD command, Line.
When a menu item is selected, AutoCAD places a blank after it. A blank in
a menu macro is interpreted as ENTER or SPACEBAR. In effect, this is
exactly the same as typing, at the command prompt "Line"
followed by ENTER.
More about Menu Macro's on the next page......
|