Will return a list.
What is a lisp routine without lists. The list can be anything from dxf code to create an entity to something to associate 2 or more values to. I’ve used list to associate engineers initials to their seal information to improve our seal recording process. Selection sets are also a list of what had been selected.
(list 1 2 3 4) returns (1 2 3 4)
Will return a real to an integer.
A coworker that uses civil needed to make a polyline that ran along a bank. He needed to just move his mouse along an image to show where the top of a ditch was. I gave the lisp 2 inputs which were start point and increment distance and it places a vertex for a polyline on where the mouse moves over the drawing area based off the previous point and the distance typed in.
(fix 2.3942) will return 2
SET and SETQ
setq are the functions of the day today. Used practically in every routine that has ever been made. You may be asking what is the difference between
setq which is a valuable question.
(setq symbol expression)
(set symbol expression)
But, those are the same arguments needed between them. You are correct but
set sets the quoted value of a symbol and
setq sets the value of a symbol.
(setq c 0)
(repeat 5 (set (read (strcat "v" (itoa (setq c (1+ c))))) c)))
is the same as
(setq v1 1)
(setq v2 2)
(setq v3 3)
(setq v4 4)
(setq v5 5)
This will allow you to save some time in setting multiple values that can be recalled later.
(subst new-list old-list list)
Make sure you have the order set correctly. Recent mistake by myself had old-list then new-list. Typically used in conjunction with
entmod but not always.
(subst (cons 1 "7-10-17") (assoc 1 lst) lst)
(vl-sort list function)
The lisp function of the day is VL-SORT. I have used this in many ways in the past but my most recent application was to find a vertical line that was the furthest to the right based on a common start point where the “Y” value was “0”.
(ssget "_x" (list (cons -4 "*,=,*") (list 10 0 0 0)))
(vl-sort xlist '>)
The first element was the furthest line to the right.