Contents at Glance

  • Introduction
  • Introducing AutoLISP
  • Storing and Running Programs
  • Organizing a Program
  • Interacting with the Drawing Editor
  • Making Decisions with AutoLISP
  • Working With Geometry
  • Working with Text
  • Interacting with AutoLISP
  • Using Lists to store data
  • Editing AutoCAD objects
  • Accessing Complex AutoCAD Objects
  • Appendix A: Menu Primer
  • Appendix B: Error Messages
  • Appendix C: Group Codes
  • Appendix D: System Variables
  • Appendix E: Table Group Codes
  • Introduction

    One of AutoCAD's greatest assets is its adaptability. You can control just about every aspect of AutoCAD's operations from the appearance of its drawing editor to its variety of menus. A key element of this adaptability is its built-in programming language, AutoLISP. With AutoLISP, you can virtually write your own commands or redefine others.

    You can think of AutoLISP as a very sophisticated macro-building facility. (Simple macros are like scripts that automate repetitive keystrokes.) You don't need to be a programmer to use AutoLISP. In fact, AutoLISP is designed so that everyday users of AutoCAD can start to use it after a minimum of training. This book makes AutoLISP accessible to AutoCAD users who are looking for a way to enhance and extend their use of AutoCAD.


    Who should read this book

    This book introduces nonprogrammers to the use of AutoLISP. If you are an intermediate level AutoCAD user, interested in learning about this powerful tool, then this is the book for you. If you are just beginning to learn AutoCAD, then you should probably become a bit more familiar with AutoCAD before attempting to learn AutoLISP. This book assumes that you have at least an intermediate level of expertise with AutoCAD and are acquainted with simple Windows operations.


    How This Book Is Organized

    The book is divided into 11 chapters. The first three chapters give you an introduction to programming in AutoLISP. The Chapter 1 introduces you to AutoLISP by showing you how to use it directly from the AutoCAD command prompt. The Chapter 2 shows you how to create and save programs in a file. Chapter 3 discusses ways of organizing your programming projects and how to manage your computers' memory.

    The next four chapters show you how to use AutoLISP to do a variety of editing tasks. Chapter 4 discusses the functions that allow you to ask the user for input. Chapter 5 explains how to build decision-making capabilities into your programs. Chapter 6 shows you how to deal with geometric problems using AutoCAD. Chapter 7 discusses the manipulation of text.

    The last four chapters show you how AutoCAD and AutoLISP interact. In Chapter 8, you will see how you can control many facets of AutoCAD through AutoLISP. Chapter 9 delves into lists, a fundamental component of all AutoLISP programs. Chapter 10 shows you ways of modifying AutoCAD objects by directly accessing the AutoCAD drawing database. And finally, Chapter 11 looks at ways to dig deeper into the drawing database to get information on complex drawing objects like polylines and block attributes.

    In addition, five appendices are included as reference material to the book. In the original version of this book, these appendices contained the resources indicated by their title. In this electronic version, these appendices offer directions on how to find information in the AutoCAD help system. The first three show you how to find information on the AutoCAD menu structure, AutoLISP error messages, and AutoCAD group codes. The fourth appendix describes how to find informaton on the standard AutoCAD dimension variables and system variables. The fifth appendix describes how to find informaton on the Table group codes.

     


    How to Use This Book

    Each chapter offers exercises and sample programs that demonstrate some general concept regarding AutoLISP. Through these exercises, the book shows you how programs develop from ideas into finished, running programs. Also, the information you learn in one chapter will build on what you learned in the previous chapter. This way, your knowledge of AutoLISP will be integrated and cohesive, rather than fragmented. For this reason, the best way to use this book is to read each chapter in order and do all of the exercises. Since the topics are oriented toward accomplishing tasks rather than simply focusing on individual functions, you will have a good grasp of how to use AutoLISP in real world situations by the end of this book.

     


    Where to Find the LISP Programs

    As you read the chapters and do the exercise, you will be asked to enter program code into a file. If you are in a hurry, you can cut and paste the code directly from the chapter you are reading. This will save a good deal of time, but make sure you study the code that you cut and paste.

     

     This book was originally published in 1990 by Sybex Inc. It has been reproduced here in an electronic format by the Author for the benefit of Mastering AutoCAD readers everywhere. Enjoy....

     


    Copyright © 1997 George Omura P.O. Box 6357 Albany, CA 94706 World rights reserved. No part of this publication may be stored in a retieval system, transmitted, or reproduced in any way, including but not limited to photocopy, photograph, magnetic or other record, without the prior agreement and written permission of the author.