|
|
Toolbar templates
1 Mar, 2002 By: Barry BowenAdd custom toolbars to your AutoLISP program interfaces.
Toolbars are an essential part of any custom program or application you write. They provide an efficient and friendly interface for users to access your program. They also keep your program separate from AutoCAD's menus.
|
|||||||||||
Here's how
To get started, use a text editor such as Notepad to create a new file
named TOOLBAR.MNS in your programming folder. This serves as the toolbar
template for all the partial toolbar menus you create. Note that we're
using the MNS extension, not the MNU extension.
In the text editor, type the lines in the box below into the open file, then save it for use later. Replace the items in italic with your own. See the next section for details on how to create your own custom toolbar icons.
Next, use the text editor to create a file that loads an AutoLISP application
menu. Save this file as TOOLBAR.MNL. It contains the following lines:
;;;TOOLBAR.MNL
(setq MYPATH c:/myprogram/)
(load (strcat MYPATH MYPROGRAM ))
(princ)
When AutoCAD loads the partial menu toolbar, the MNL file of the same name loads and executes, setting the path (MYPATH) and loading the AutoLISP program (MYPROGRAM).
| Figure 1. Smiley faces indicate missing bitmaps. |
Create your icons
You can create image bitmaps for the toolbar icons in the AutoCAD toolbar
editor or in other programs such as Microsoft Paint. Small bitmap images
measure 1615 pixels in size, which AutoCAD 2000 stretches when Large buttons
are on. Be sure to store the image files in the same folder as the menu
file and add the path in AutoCAD. Loading the menu file without letting
AutoCAD know where the bitmap images are results in a toolbar with smiley
faces, as shown in figure 1.
I see smiley faces
Smiling faces in your toolbar indicate that AutoCAD could not find the
icon bitmaps. To correct this, make sure you added the path to the bitmaps.
In AutoCAD, select Tools | Options from the pull-down menu. On the File
tab click the plus sign (+) before the Support File Search Path. Click
the Add button, then Browse to locate the folder that holds the program
bitmaps.
Select OK, then close the dialog box and AutoCAD. Open Windows Explorer and locate the folder where you stored the menu and image files. Delete the MNC and the MNR menu files. When you start AutoCAD again, the toolbar icons should appear correctly.
Because of the limited space for this article, I have included a sample program and toolbar to further illustrate how to apply the toolbar template to a sample custom program. You can download all the related code.
Code for Toolbar.MNS |
|||
|
|||
|
|
AutoCAD Tips!
Autodesk Technical Evangelist Lynn Allen guides you through a different AutoCAD feature in every edition of her popular "Circles and Lines" tutorial series. For even more AutoCAD how-to, check out Lynn's quick tips in the Cadalyst Video Gallery. Subscribe to Cadalyst's Tips & Tricks Tuesdays free e-newsletter and we'll notify you every time a new video tip is available. All exclusively from Cadalyst! |
![]() | Feed
Place your DWG File on a Diet 18 Jun, 2013 |
![]() | Feed
Tech Toys 360: Pro-Form Le Tour de France Bike 18 Jun, 2013 |
![]() | Feed
Update 3 now available for Revit 2013 Products - Revit Clinic 18 Jun, 2013 |
![]() | Feed
Nice Design—What Does It Feel Like? 17 Jun, 2013 |
![]() | Feed
LiveMap: The Augmented Reality Motorcycle Helmet of the Future? 18 Jun, 2013 |
|








