Читать книгу AutoCAD Platform Customization - Ambrosius Lee - Страница 9
Introduction
AutoLISP in AutoCAD
ОглавлениеAutoLISP is the most popular, and is the original supported programming language for the AutoCAD program. The reason for its popularity with new (and even veteran) programmers is that it is a natural extension of the AutoCAD program. There is no additional software to purchase, and AutoLISP can leverage the commands that Autodesk and third-party developers expose at the Command prompt. For example, with a few simple lines of code you can set a layer current and insert a title block with a specific insertion point, scale, and rotation. The block is then inserted on the layer you specified. To perform the same tasks manually, the end user would have to first set a layer current, choose the block they want to insert, and specify the properties of the block, which in the case of a title block are almost always the same.
The AutoLISP programming language can be used to:
• Create custom functions that can be executed from the AutoCAD Command prompt
• Create and manipulate graphical objects in a drawing, such as lines, circles, and arcs
• Create and manipulate nongraphical objects in a drawing, such as layers, dimension styles, and named views
• Perform mathematical and geometric calculations
• Request input from or display messages to the user at the Command prompt
• Interact with files and directories in the operating system
• Read from and write to external files
• Connect to applications that support ActiveX and COM
• Display dialog boxes and get input from the end user
AutoLISP code can be entered directly at the Command prompt or loaded using a LSP file. Once an AutoLISP program has been loaded, you can execute the custom functions from the Command prompt. Functions executed from the Command prompt can be similar to standard AutoCAD commands, but the programmer determines the prompts that should be displayed. It is also possible to use AutoLISP code with a command macro that is activated from the AutoCAD user interface or a tool on a tool palette.