AfraLisp Blog

The AutoLisp/Visual Lisp/VBA Resource Website

AfraLisp Blog

Home Newsletter Utter Rubbish Coding Tips AutoCAD Tips Contact Downloads WAUN

Page I. Home Page III. Page IV.

Creating Menu's - Page II.

Menu Macro's

Let's look at some Special Menu Characters : 

[ ]		Encloses a Menu Label.
;		Enter.
Space		Enter or Spacebar.
\		Pauses for user input.
_		Translates AutoCAD commands.
+		Continues menu macro to next line.
*^C^C		Prefix for repeating Item.
$		Character Code that loads a menu section.
^B		Toggels Snap/Off.
^C		Cancels command.
^D		Toggles Coords.
^E		Sets the next Isometric Plane.
^G		Toggles Grid On/Off.
^H		Issues Backspace.
^O		Toggles Ortho On/Off.
^P		Toggles Menuecho On/Off.
^Q		Echoes all prompts.
^T		Toggles Tablet On/Off.
^V		Changes current Viewport.
^Z		Null Character.

I don't really want to get too involved with Menu Macro's, but here is a few sample Macro's to show you the general idea : 

***MENUGROUP=TEST2

***POP1
P1-1[&Test Menu2]
P1-2[&Layer 2 On]^C^CLayer;M;2;;
P1-3[&Ortho On/Off]^C^C^O
P1-4[Change to Layer 3]*^C^CChange;\;P;LA;3;;
P1-5[&Hello World](alert "Hello World")
Your Menu should look like this :

M3

The first Menu Item is again, the menu label.
The second item changes the current layer to layer 2.
(Layer Enter Make Enter 2 Enter Enter).
The third item simply toggles Ortho On or Off.
The fourth item let's you select an object and changes it to layer 3.
(Change Enter Pause Enter Properties Enter Layer Enter 3 Enter Enter).
The * prefix will force the macro to repeat until the user hits CTRL-C or ESC.
The fourth item demonstrates the use of AutoLISP within a menu item.

Menu macro's can get quite long and complicated but my advice to you is, rather write an AutoLISP routine than try and design complicated macro's.
Look at this for a macro :

[Box](setq a (getpoint "Enter First Corner: "));\ +
(setq b (getpoint "Enter Second Corner: "));\+
pline !a (list (car a)(cadr b))!b (list (car b) (cadr a))c;

Crazy, Hey. As I said, rather write an AutoLISP routine. You can do a hell of a lot more and, create a much more professional routine using AutoLISP than you ever will trying to write super-duper, 20 line macro's.

Just one small point about the above macro. Did you notice the use of the special character + at the end of some of the lines. This allows the macro to continue to the next line.

Anyway, enough about menu macro's. Let's have a look at some special label characters that you can use in pull-down menu's. 

--		Item label that expands to become a separator line.
+		Continues macro to next line.
->		Label prefix that indicates that the pull-down menu item
		has a submenu
<-		Label prefix that indicates that the pull-down menu item
		is the last item in a submenu.
<-<-..		Label prefix that indicates that the pull-down menu item
		is the last item in the submenu, and terminates the parent
		menu. One <- is required to each terminate each parent menu.
~		Lable prefix that disables a menu item.
!.		Label prefix that marks a menu item.
&		Label prefix that defines shortcut key.
On the next page we will have a look at an example menu using
some of these special characters.

Page I. Home. Page III. Page IV.
 
The AutoLisp/Visual Lisp/VBA Resource Website

Copyright © 1999-Perpetuity by AfraLisp

All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage

The AutoLisp/Visual Lisp/VBA Resource Website