PDA

View Full Version : Using an external look-up csv table for variable translation



orourkestuart792771
2020-12-03, 06:44 AM
I've got a LISP that currently works on a block attribute 'CODE' and I've got a .csv used for translating drawing layers from one nomenclature to another.

If in the csv column 1 is 'CODE' and column 2 is 'LAYER' how do I tell the LISP I've got to exchange CODE for LAYER? This is the basic LISP:

(defun c:ASLX ( / )

(varopen)
(setq Blnamex (car(entsel "\nSelect:")))
(setq SIZE () material () code ())
(GATTRIB Blnamex)
(CoordBL Blnamex)
(MatSiText Size Material)
(setq leadlay (strcat code "-TEXT"))
(COMMAND "-LAYER" "M" leadlay "")
(COMMAND "_MLEADER" coord PAUSE TX)
(Varclose)
(princ)
)

I know there's a lot of other functions happening in here, but I just need some way of using the CODE variable to look-up a csv and return the LAYER valu. ATM I've got a long workaround that uses the CODE and suffixes it with -TEXT so I can isolate and manually shift the Mleaders into the required layers. ANy help appreciated.

BIG-AL
2020-12-07, 05:55 AM
You can either read a file line by line look for match.

Or convert csv to a list then step through list looking for match ((code1 layer1)(code2 layer2)...

There is plenty of read csv to list out there start with Lee-mac.com

If talking survey codes we had like 250+ not huge, there is a method 10,000 entries takes 13 goes max to find to do with indexing.