Name Data Type Description

MenuFileName String The path and file name of the menu file to be loaded.

BaseMenu Boolean This optional parameter determines whether the menu group is loaded as a base or partial menu. If it's set to True, then the menu group is loaded as a base menu. Otherwise, the menu group is loaded as a partial menu. The default is False.

Using the Load method with the BaseMenu parameter set to True equates to executing the MENU command inside the AutoCAD application and selecting a file through the Select Customization File dialog box (see Figure 16-1). Alternatively, you can execute the MENULOAD or CUILOAD command and check the Replace All option in the Menu Customization dialog box (see Figure 16-2). The newly loaded menu file becomes the only loaded menu group and completely replaces the previous menu bar.

^Select Customization File

Ir^Acadm

A

^ til X ¥¡ews ' TQOJS ▼

Name *

i

Size

Type

1 Date Modified

II^i n3v

F

e Folder

5/5/2005 5:39 Pf*

QGe3

F

e Folder

5/5/2005 5:39 Pf*

ÖGef

F

e Folder

5/5/2005 5:39 Pf*

ÖGen

F

e Folder

5/5/2005 5:39 Pf*

Ö Migration

F

e Folder

5/5/2005 5:36 Pf*

Qsys

F

e Folder

5/5/2005 5:39 Pf*

Ir^l Template

F

e Folder

5/5/2005 5:39 Pi^

ö Tools

F

e Folder

5/5/2005 5:39 Pf*

Ir"! Translator

F

e Folder

5/5/2005 5:38 Pf*

Ö Tutorial

F

e Folder

5/5/2005 5:38 Pf*

|lï] acadm

.,525 KB

AutoCAD Customiza..

3/7/2005 10:37

[Ü1 acadmac

252 KB

AutoCAD Customiza..

3/7/2005 10:37

Ujacadmfly

359 KB

AutoCAD Customiza..

J Jj

Figure 16-1. Using the Select Customization File dialog box to load a menu file

Figure 16-2. Using the Menu Customization dialog box to load a menu group

Alternatively, using the Load method with the BaseMenu parameter set to False equates to executing the MENULOAD or CUILOAD command inside the AutoCAD application and selecting a file through the Menu Customization dialog box. The menu group is loaded in addition to the already existing menu groups.

To find out what type of menu groups are loaded into an AutoCAD session, you can examine the Type property for each MenuGroup object.

lngMenuGroupType = MenuGroupObject.Type

This read-only property holds one of the AcMenuGroupType constants listed in Table 16-2.

Table 16-2. The AcMenuGroupType Constants

Constant

Value

Description

AcBaseMenuGroup

0

The menu group is a base menu group.

AcPartialMenuGroup

1

The menu group is a partial menu group.

The following code lists all the currently loaded menu groups and their types:

Public Sub ListMenuGroups() Dim objMenuGroup As AcadMenuGroup Dim strMenuGroupNames As String strMenuGroupNames = "The following menu groups are currently loaded, "

For Each objMenuGroup In Application.MenuGroups If objMenuGroup.Type = acBaseMenuGroup Then strMenuGroupNames = strMenuGroupNames & vbCrLf & _

objMenuGroup.Name & ": Base menu"

Else strMenuGroupNames = strMenuGroupNames & vbCrLf & _

objMenuGroup.Name & ": Partial menu"

End If

Next

MsgBox strMenuGroupNames End Sub

For my setup, this code yields the result shown in Figure 16-3.

Note that the MenuGroups collection doesn't expose an Add method, so you can't create new menu groups through code. However, you can copy an .mns file, give it a new file name, and then load and edit it as you require. You can also write a new .mnu or .mns file and load it entirely from VBA. It's usually best to work with partial menus and avoid modifying or replacing the AutoCAD menu system entirely, for two main reasons:

• You don't want to upset your users (customers) by changing the familiar menu system entirely.

• Keeping your menus separate avoids the possibility of an AutoCAD service pack wiping out your hard work.

Until you feel confident with the material covered in this chapter, you should make a copy of an existing menu group file, unload the original, and load and use this copy to try the code in this chapter. You can then unload the copy and reload the original to restore your original AutoCAD menu structure.

Was this article helpful?

0 0

Post a comment