Setq function is used to store a value in a variable. The syntax for setq function is:
(setq variable_name variable_value)
e.g.
(setq no1 10)
(setq no2 20)
(setq sum (+ no1 no2))
First statement stores the value 10 in variable no1, second statement stores 20 in variable no2. Third statement stores the sum of no1 & no2 i.e. 30 in variable sum.
You can try above statements on AutoCAD command prompt.
To view the value store in a variable, on AutoCAD command prompt use the '!' operator before the variable name.
e.g.
!no1 will return 10
!no2 will return 20
!no3 will return nil (If the variable is not defined, it will return nil)
!sum will return 30
Try following statements on AutoCAD command prompt.
(setq company "CADDsoft")
(setq value 10.25)
(setq mydiv (/ value 2))
You can retrieve the values stored in above variables as shown below:
!company
!value
!mydiv
- Free Download AutoLISP, VisualLISP, DCL Books.
- Watch AutoLISP Video Tutorials