About-Swapping-and-Inserting-Pull-Down-Menus

About Swapping and Inserting Pull-Down Menus

About Swapping and Inserting Pull-Down Menus

Workspaces can be used to control which pull-down menus are displayed on the menu
bar. However, you can also swap one pull-down menu programmatically for another (for
example, when a user loads an application that requires an additional pull-down menu).

Swap Pull-Down Menus

Because the program has cascading pull-down menus, there is little need to swap menus.
Also, swapping menus can detract from the consistency of the user interface. However,
using $ commands, you can swap pull-down menus and submenus. An alternative to menu swapping
involves relative (or global) referencing. Using this method, you can insert the new
menu in front of a known menu and then remove the known menu.

For menu-swapping purposes, pull-down menus are named P1 through P16. You can change the title that appears on the menu bar by replacing that line of
the menu with a $Pn= command. You can use the special command $Pn=* from within any command to force the menu currently assigned to the alias POPn to pull down for greater flexibility in movement of the pointing device.

The following macro example replaces a pull-down menu at position P3 with the menu named new3 in the customization group named MYMENU.

$P3=mymenu.new3

In AutoCAD, the same thing can be done with the AutoLISP menucmd function as follows:

(menucmd "P3=mymenu.new3")
NOTE:AutoLISP is not available in AutoCAD LT.

You can use the $Pn=* special command from within any macro to force the menu currently assigned to area
POPn to be displayed.

NOTE:The swapping of pull-down menus does not conform to the Microsoft آ® user interface VCadelines and is not guaranteed to be available in future releases
of the program.

Menu swapping is done by activating one menu directly from another menu. Menu swapping
is supported for the following interface elements:

  • B – Buttons
  • P – Pull-down menus
  • A – Mouse buttons
  • I – Image tile menus
  • T – Tablet menus

The syntax for the swapping of partial menus is as follows:

$section=customizationgroup.menuname

section

Valid section names are B1-4, A1-4, P0-16, T1-4

customizationgroup

Customization group name in the desired customization (CUIx) file

menuname

Main label or alias

You should be aware of the following:

  • Image tile menus cannot be swapped from external customization files.
  • You can swap customization elements of the same type only; that is, one shortcut menu
    for another, one toolbar for another, and so on. Trying to swap between types may
    result in unpredictable behavior.

Insert and Remove Pull-Down Menus

You can use the AutoLISP menucmd function (not available in AutoCAD LT) to insert or remove a pull-down menu. The
syntax is similar to that used to swap pull-down menus except that the left side of
the assignment is the pull-down menu before which the new menu will be inserted. The
right side of the assignment is a plus sign (+) followed by the name of the customization group, a period, and the menu’s alias,
as shown in the following syntax:

(menucmd "Gcustomizationgroup1.menuname1=+Gcustomizationgroup2.menuname2")

You can also insert a menu with the Pn= syntax. The following macro inserts a menu after the P5 menu:

$P5=+Gmymenu.new3

The same macro can be implemented with AutoLISP using the following:

(menucmd "P5=+Gmymenu.new3")

If you use this method to insert a menu, remember that you cannot rely on it being
inserted at the P6 menu location as you might expect. There are two reasons that this may not be the
case.

  • If the current menu bar has only three menus, inserting a menu after menu P5 results in the new menu’s location being P4.
  • If the user inserts or removes a customization (CUIx) file with the CUILOAD command
    or when another application inserts or removes pull-down menus, menu numbering can
    get out of sync.

This is the syntax for removing a menu:

Gcustomizationgroup.menuname=-

Removing a menu with AutoLISP would using the following syntax:

(menucmd "Gcustomizationgroup.menuname=-")

The following shows how to remove the menu NEW3 that is a member of the MyMenu group.

$Gmymenu.new3=-"

The previous example would look like the following in AutoLISP:

(menucmd "Gmymenu.new3=-")

As you might expect, the preceding format is preferable to the Pn= format because it removes only the specified menu. The following shows how to remove
the menu at the P4 location (whatever it is).

$P4=-

The previous example would look like the following in AutoLISP:

(menucmd "P4=-")
NOTE:Use the Pn syntax as part of the syntax for the AutoLISP menucmd function only. Use the $Pn syntax for macro-specific statements.

Control Toolbars Across Partial Customization (CUIx) Files

Toolbar are commonly displayed using workspaces. However, you can display a toolbar
using the -TOOLBAR command. Use the following syntax at the

Enter toolbar name or [ALL]:

prompt.

customizationgroup.toolbaralias

This syntax accesses the toolbar identified by customizationgroup.toolbaralias.

If the customization group is left out, the program defaults to the main customization
(CUIx) file.

Learning AutoCad