Autolisp / Visual Lisp - Part 1 Autolisp / Visual Lisp: Robert Green
Autolisp / Visual Lisp - Part 1 Autolisp / Visual Lisp: Robert Green
Robert Green
CAD-Manager.com
((defun C:ZA ()
(command .zoom a)
(p
(princ)
)
)
(defun C:BL ()
(command -color BYLAYER)
(command -linetype set BYLAYER )
(princ)
)
Undefine
Dot form
Redefine
Alerts
Al t
CMDECHO
(COND
( (TEST EXPRESSION 1) (OUTCOME) )
( (TEST EXPRESSION 2) (OUTCOME) )
( (TEST EXPRESSION 3) (OUTCOME) )
)
(OBTAIN VARIABLE)
(WHILE (TEST EXPRESSION ON VARIABLE)
(Statement 1)
.
(Statement N)
)
(setq spokes 0)
(while (< spokes 20)
(setq spokes (getint \nEnter number of spokes: ))
)
The WHILE function loops around until the test case is satisfied
Hint:
Use WHILE to qualify the input, use
COND to evaluate the cases
(cond
( ((< spokes
p 10)) ((alert SMALL WHEEL)) )
( (and (>= spokes 10) (<= spokes 15)) (alert MEDIUM WHEEL) )
( (> spokes 15) (alert LARGE WHEEL) )
)
Note: You can use the set with any AutoCAD command with
the convenience of storing the sets as variables that you can
create with filters.
Could you write a program that would ask the user for a layer
name then
th change
h allll objects
bj t ffound
d on th
thatt llayer ((assuming
i
it exists) to the layer NEW that has a color of GREEN?
Pseudo code:
Prompt for layer name
Find objects on layer
Use LAYER to create new layer
Use CHANGE to change objects
Youll g
get MYPROG.FAS as a result
Now y
your LSP code is secure!
Be sure not to lose your LSP code though!