这是版本1,它将读取文件位,它将是lotnum,layername文件名,例如c:/temp/lisp/lots。csv
- ; reads a csv file lotnum,layername and changes hatch located a text point
- ;by Alan H May 2014 thanks also to Lee-mac
- ;; String to List - Lee Mac
- ;; Separates a string using a given delimiter
- ;; str - [str] String to process
- ;; del - [str] Delimiter by which to separate the string
- ;; Returns: [lst] List of strings
- (defun LM:str->lst ( str del / pos )
- (if (setq pos (vl-string-search del str))
- (cons (substr str 1 pos) (LM:str->lst (substr str (+ pos 1 (strlen del))) del))
- (list str)
- )
- )
- (defun HATLOT (lotnum col / HATOBJ FPTS PT1 TPT )
- (SETQ OLDSNAP (GETVAR "OSMODE"))
- (SETVAR "OSMODE" 0)
- (setq lotfound (ssget "X" (LIST (CONS 0 "MTEXT")(CONS 1 lotnum)(CONS 8 "C-BLDG-NMBR"))))
- (SETQ TPT (ASSOC 10 (ENTGET (ssname lotfound 0))))
- (SETQ PT1 (LIST (NTH 1 TPT)(NTH 2 TPT)))
- (SETQ FPTS (LIST (POLAR PT1 1.57 2 ) PT1)) ; 2 is a dummy value just past text hole
- (SETQ HATOBJ (ENTGET (SSNAME (SSGET "f" FPTS '((0 . "HATCH"))) 0)))
- (ENTMOD (subst col (assoc 8 HATOBJ) HATOBJ))
- )
- ; this is where you would loop through the lots csv from excel number - color
- ; next version
- (setq fopen (open (getstring "\nEnter file name") "R"))
- (while (setq strline (read-line fopen))
- (setq retstr (LM:str->lst strline ","))
- (setq lotnum (nth 0 retstr)) ; read from file
- (SETQ COL (nth 1 retstr)) ; read from file
- (HATLOT lotnum col)
- ) ; end while
- (setvar "osmode" oldsnap)
- (princ)
|