Skip to content

Commit 992b9cb

Browse files
committed
Refactor AutoLISP Basics documentation to improve structure and add new examples
1 parent 1fb717d commit 992b9cb

1 file changed

Lines changed: 33 additions & 6 deletions

File tree

docs/AutoCAD/AutoLISP Basics.md

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- Trace Window : This is useful for debugging, showing the flow of execution.
1414
- You can Use `Appload` button or `Ctrl + F9` to load your lisp code into AutoCAD.
1515
- 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
1617

1718
## Sample Code
1819
- Here is a simple AutoLISP function that prints "Hello, World!" to the command line when you type `hello` in AutoCAD.
@@ -23,7 +24,7 @@
2324
)
2425
```
2526

26-
## AutoLISP Functions
27+
## Basic Syntax
2728

2829
### Comments
2930
- Use `;` to add comments in your code. Anything after `;` on the same line is ignored by AutoLISP.
@@ -46,14 +47,17 @@
4647
(alert "This is a message box!")
4748
```
4849

49-
### Command
50-
- Used to execute AutoCAD commands from within AutoLISP.
50+
### If Statement
51+
- Used for conditional execution of code.
5152
```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+
)
5357
```
5458

55-
### If Statement
56-
- Used for conditional execution of code.
59+
### IF Else Statement
60+
- Used for conditional execution with an alternative path.
5761
```lisp
5862
(if (> 10 5)
5963
(princ "10 is greater than 5")
@@ -69,7 +73,30 @@
6973
)
7074
```
7175

76+
## Special Functions
7277

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+
```
73100

74101
### Table Search
75102
- Used to search for a value in a list or table.

0 commit comments

Comments
 (0)