Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Autocad 2005 And Autocad LT 2005 Bible (2004).pdf
Скачиваний:
92
Добавлен:
17.08.2013
Размер:
32.22 Mб
Скачать

Chapter 33 Customizing Menus 981

The code osmode 1 sets an endpoint object snap; osmode 7 sets object snaps for endpoint, midpoint, and center.

5.Save the file as ab5.mnu in your Support folder or another folder in the support-file search path. Minimize Notepad.

6.Open a new drawing using the acad.dwt or aclt.dwt template. Choose Zoom All from the Zoom flyout on the Standard toolbar. Choose Tools Customize Menus. On the Menu Groups tab, make sure that the Replace All check box is not checked. In the File Name text box, type ab5.mnu and click Load. Click Yes at the message warning you about overwriting toolbar changes. The menu file loads.

7.Choose the Menu Bar tab. Choose Window on the Menu Bar list and click Insert to insert the partial menu to the left of the Window menu. Click Close.

8.Choose Tools Customize Keyboard. From the Menu Group list, choose AB5. From the Commands drop-down list, choose 4 Circles.

9.Click the Press New Shortcut Key text box. Press F12. Click Assign and then click Close to close the dialog box.

10.Press Ctrl+up arrow (the up arrow on your keyboard). The snap changes to 1. Press Ctrl+down arrow. The snap changes to 0.25. (If the cursor doesn’t snap to the setting, you have PolarSnap on. Right-click SNAP on the status bar and choose Grid Snap On.)

11.Right-click OSNAP and choose Settings. In the Drafting Settings dialog box, uncheck all object snap modes and click OK.

12.Draw a line and a circle. Start the LINE command. At the Specify first point: prompt, press Ctrl+E. Pick either endpoint of the line. At the Specify next point or [Undo]: prompt, point to the circle and verify that you can’t find its Center object snap.

13.Press Ctrl+8 (on the keyboard). Now pick the circle’s Center object snap and end the LINE command.

14.Press F12. The 4 Circles menu item executes, drawing four circles.

15.Choose Tools Customize Menus to unload the AB5 menu group.

Don’t save your drawing.

Summary

In this chapter, you read about how to customize the menu to suit your situation and speed up your everyday work. Menu customization is very powerful. When you start customizing your menus, you suddenly find yourself thinking of new ways to use this option. The result will be a major improvement in the way AutoCAD or AutoCAD LT serves your needs.

This chapter ends Part VI, “Customizing AutoCAD and AutoCAD LT.” Part VII challenges you to go further in your customization of AutoCAD by starting to program with AutoLISP and Visual Basic for Applications.

 

 

 

Programming

AutoCAD

Part VII invites you to go the distance and start programming AutoCAD with AutoLISP, Visual LISP, and Visual Basic for Applications (VBA). AutoLISP is a powerful programming language that lets you quickly create your own commands and routines tai-

lored to your needs. Visual LISP adds an easy-to-use interface to AutoLISP programming.

VBA is a programming language that is supported by many Windows applications. You can create programs and dialog boxes for AutoCAD with VBA. Using ActiveX, which lets you access other Windows applications, you can write programs that integrate AutoCAD with other applications.

Unfortunately, AutoCAD LT doesn’t support either AutoLISP or VBA. Therefore, this entire part applies only to AutoCAD.

P A R T

VII

In This Part

Chapter 34

Understanding AutoLISP

and Visual LISP Basics

Chapter 35

Exploring AutoLISP

Further

Chapter 36

Exploring Advanced

AutoLISP Topics

Chapter 37

Programming with

Visual Basic for

Applications

Understanding

AutoLISP and

Visual LISP Basics

AutoLISP is a programming language that can substantially enhance your productivity by automating often-used or repeti-

tive tasks. AutoLISP provides a glimpse into the inner workings of AutoCAD and can serve as an excellent stepping stone to learning more-advanced automation methods, such as ObjectARX and VBA. An AutoLISP routine gives you complete control of its interaction with the user and what it does after it’s loaded.

AutoCAD LT doesn’t support AutoLISP, unfortunately.

You can type AutoLISP expressions on the command line in response to prompts, or you can save your code to a file that you can load and use when needed. AutoLISP offers wide and varied possibilities for shortcuts. Best of all, you can customize AutoLISP to any level of complexity.

AutoLISP intimidates many AutoCAD users, but this fear is unwarranted. The many benefits of AutoLISP well justify the initial time you invest to learn this rich and full-featured programming language.

You can also find a tremendous number of AutoLISP routines. Many CAD Web sites offer huge libraries of AutoLISP routines as free downloads. (For more details, see Bonus Chapter 2 on the CD.) Every office with more than a trivial number of AutoCAD workstations has probably created at least one AutoLISP routine to expedite some common task.

Many of the commands you already use in AutoCAD are in AutoLISP routines, including 3DARRAY, MVSETUP, AI_BOX, and others. You can often get examples of how to handle complex problems by reviewing these applications.

LISP stands for List Processing, and as you’ll see in the next chapter, the understanding of lists is crucial to using AutoLISP.

Most AutoLISP routines define a command name, which you then type at the command line to run the routine. Some routines include a dialog box to help you choose options and specifications.

34C H A P T E R

In This Chapter

Understanding AutoLISP programming and the Visual LISP environment

Working with the

Visual LISP interface

Getting help in

Visual LISP

Creating your own

AutoLISP expressions

Using AutoLISP on the command line