Training

 
AutoLISP & VisualLISP
DCL-Dialog Control Language
 
AutoCAD VBA
 
ObjectARX
 
AutoCAD.Net
 
Inventor API
 
SolidWorks API
 
SolidEdge API


Articles

AutoCAD.Net
 
AutoCAD VBA
 
AutoLISP
 
VisualLISP
 
AutoCAD Customization
 
SolidWorks VBA
 
SolidEdge VBA
 

Download

AutoCAD.Net Code
 


Tutorials

AutoCAD 3D Press-Pull
 
 


Services

AutoCAD Customization
 
CAD Customization
 
SolidWorks Customization
 

 

Articles > AutoLISP - Using setq function

 

Using AutoLISP setq function on AutoCAD command prompt:

 

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

View Tutorial video on AutoLISP - Using setq function

 

Related links:

 

       Read article on VisualLISP, AutoCAD customization, AutoCAD VBA

       Learn AutoCAD Customization using AutoLISP & VisualLISP, DCL, AutoCAD VBA, AutoCAD.Net, ObjectARX

       Learn other CAD Customization tools such as SolidWorks API, SolidEdge API, Inventor API

 

Copyright 2008-2011 CADDsoft Solutions, all rights reserved