Lisp of the Day

LIST

(list list)

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)

Advertisements

Lisp of the Day

FIX

(fix number)

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

Lisp of the Day

 

SET and SETQ

Good old set and 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 set and 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.

Lisp of the Day

VL-SORT

(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”.

;Selecting filter
(ssget "_x" (list (cons -4 "*,=,*") (list 10 0 0 0)))
;Sorting
(vl-sort xlist '>)

The first element was the furthest line to the right.