|
13 | 13 | - Trace Window : This is useful for debugging, showing the flow of execution. |
14 | 14 | - You can Use `Appload` button or `Ctrl + F9` to load your lisp code into AutoCAD. |
15 | 15 | - You can add your Lisp file to Startup Suite so that it loads automatically when AutoCAD starts. |
| 16 | +- You can also run Lisp Code Directly in AutoCAD Command Line |
16 | 17 |
|
17 | 18 | ## Sample Code |
18 | 19 | - Here is a simple AutoLISP function that prints "Hello, World!" to the command line when you type `hello` in AutoCAD. |
|
23 | 24 | ) |
24 | 25 | ``` |
25 | 26 |
|
26 | | -## AutoLISP Functions |
| 27 | +## Basic Syntax |
27 | 28 |
|
28 | 29 | ### Comments |
29 | 30 | - Use `;` to add comments in your code. Anything after `;` on the same line is ignored by AutoLISP. |
|
46 | 47 | (alert "This is a message box!") |
47 | 48 | ``` |
48 | 49 |
|
49 | | -### Command |
50 | | -- Used to execute AutoCAD commands from within AutoLISP. |
| 50 | +### If Statement |
| 51 | +- Used for conditional execution of code. |
51 | 52 | ```lisp |
52 | | -(Command "LINE" (list 0 0) (list 100 100) "") |
| 53 | +(if (> 10 5) |
| 54 | + (princ "10 is greater than 5") |
| 55 | + (princ "10 is not greater than 5") |
| 56 | +) |
53 | 57 | ``` |
54 | 58 |
|
55 | | -### If Statement |
56 | | -- Used for conditional execution of code. |
| 59 | +### IF Else Statement |
| 60 | +- Used for conditional execution with an alternative path. |
57 | 61 | ```lisp |
58 | 62 | (if (> 10 5) |
59 | 63 | (princ "10 is greater than 5") |
|
69 | 73 | ) |
70 | 74 | ``` |
71 | 75 |
|
| 76 | +## Special Functions |
72 | 77 |
|
| 78 | +### Setq |
| 79 | +- Used to assign values to variables. |
| 80 | +```lisp |
| 81 | +(setq myVariable 10) |
| 82 | +(princ myVariable) ; This will print 10 |
| 83 | +``` |
| 84 | + |
| 85 | +### GetPoint |
| 86 | +- Used to get a point from the user in the drawing area. |
| 87 | +```lisp |
| 88 | +(setq userPoint (getpoint "\nSelect a point: ")) |
| 89 | +(princ userPoint) ; This will print the selected point coordinates |
| 90 | +``` |
| 91 | + |
| 92 | +### Command |
| 93 | +- Used to execute AutoCAD commands from within AutoLISP. |
| 94 | +- `""` is used to indicate the end of a command sequence, similar to pressing Enter. |
| 95 | +```lisp |
| 96 | +(setq a (getpoint "\nEnter First Point : ")) |
| 97 | +(setq b (getpoint "\nEnter Second Point : ")) |
| 98 | +(Command "LINE" a b "") |
| 99 | +``` |
73 | 100 |
|
74 | 101 | ### Table Search |
75 | 102 | - Used to search for a value in a list or table. |
|
0 commit comments