Download Autodesk - Free AutoLISP Course...
AutoLISP Course
By Jos van Doorn. AutoCAD specialist and AutoLISP programmer. Also publisher ACAD Newsletter. About AutoCAD and AutoLISP. FREE. To subscribe send an e-mail to: mailto:
[email protected]
© Jos van Doorn 2003
1
AutoLISP Course
Overview Overview ....................................................2 Introduction ................................................3 Lesson 01: About AutoLISP ...................................5 Lesson 02: Entities .........................................7 Lesson 03: Setting Values ...................................9 Lesson 04: Arithmetic Functions 1 ..........................12 Lesson 05: Arithmetic Functions 2 ..........................16 Lesson 06: Arithmetic Functions 3 ..........................18 Lesson 07: Creating Drawings 1 .............................22 Lesson 08: Creating Drawing 2 ..............................26 Lesson 09: Getting Information 1 ...........................30 Lesson 10: Getting Information 2 ...........................33 Answers ....................................................36 What next? .................................................40 ACAD Newsletter ............................................42
© Jos van Doorn 2003
2
AutoLISP Course
Introduction Thanks for requesting the AutoLISP course. After reading and studying this course you will be able to write your own AutoLISP routine. AutoLISP is a very powerful feature of AutoCAD. In AutoLISP you can write your own routines that can be used for creating AutoCAD drawings. That's what you will see. AutoLISP is very fast. Using an AutoLISP routine an AutoCAD drawing is created in less than one second. You want to learn programming in AutoLISP. That's why you are doing this course. I think that's a very wise decision. That will help you a lot. You know how it is. You're working with AutoCAD. All the time you've got these repetitive tasks. Don't do them by hand. Use an AutoLISP routine. I mentioned it before. AutoLISP is very powerful. Anything you can do in AutoCAD can be done using an AutoLISP routine. Anything! You can use AutoLISP routines to create parts of an AutoCAD drawing. But you can also use it to create a complete AutoCAD drawing. To create an AutoCAD drawing by hand takes hours. Sometimes it takes days. An AutoLISP routine can do the job within one second. That's a time saver. This course will help you to get started with programming in AutoLISP. In every lesson is an exercise. The exercise is about what has been explained in the lesson. Maybe you've got a problem. If so come to me. Ask me what's bordering you. Or what you cannot solve. And I'll give you an answer. You can send me an e-mail. Write "Problem" in the subject line. Then I can see where your e-mail is about. This is my e-mail address: mailto:
[email protected]
Steal this e-book Easy. Give this e-book away to other people that are interested in AutoLISP programming. Or send it to them by e-mail. Or put it on your web site. One thing. This e-book is a no cost e-book. It cannot be sold. It can only be given away. Because I’m giving it away. At no cost.
© Jos van Doorn 2003
3
AutoLISP Course
Have a good course.
Jos van Doorn. AutoCAD specialist and AutoLISP programmer. Also publisher ACAD Newsletter. About AutoCAD and AutoLISP. FREE. To subscribe send an e-mail to: mailto:
[email protected]
© Jos van Doorn 2003
4
AutoLISP Course
Lesson 01: About AutoLISP AutoLISP is one of the dialects of the programming language LISP. LISP has been developed by John McCarthy in the fifties. LISP was the second higher programming language after FORTRAN. I was never really popular. That changed in the eighties. LISP is short for LIst PRogramming or LIst PRocessing. But they say it is also short for "Lots of Stupid Parentheses". AutoLISP is a programming language that is interpreted. AutoLISP is not compiled. The advantage is that mistakes can easily be detected.
Why wait for hours or even days? Get your AutoCAD drawings right away! Find out how. Send an e-mail to: mailto:
[email protected] A further explanation of AutoLISP will be given later. But let's start with an example of how AutoLISP can be used when drawing in AutoCAD. Suppose we want to insert a block. And the block must have a scale of three divided by seven. You can calculate that number or use AutoLISP. This is how you can do it:
For the x-scale (/ 3.0 7) is entered at the prompt. That means three divided by seven. AutoLISP makes the calculation and comes with 0.428571. This is a feature of AutoLISP you can use right away. But there is more to do than division. Here's an overview of other arithmetic functions: Action Addition subtraction multiplication
Function (+