使用CSV文件中的属性块
嗨,伙计们,我有这个代码,上传信息从一个CSV文件与坐标和值。我想知道这样做是否会太复杂,不是创建点和文本,而是为每个坐标后有值的列创建一个带有属性的块。; thanks to Lee-mac for this defun
; www.lee-mac.com
; 44 is comma 32 is space
(defun _csv->lst ( str / pos )
(if (setq pos (vl-string-position 44 str))
(cons (substr str 1 pos) (_csv->lst (substr str (+ pos 2))))
(list str)
)
)
(defun C:samples(/ data file enx obj old new)
(setq fo (open (getfiled "Select CSV File" "" "csv" 16) "R"))
(setq lst '())
(while (setq nline (read-line fo))
(setq lst (cons (_csv->lst nline) lst))
(setq lst (nth 0 lst))
(setq ID (nth 0 lst) X (nth 1 lst) Y (nth 2 lst) Z (nth 3 lst) AU (nth 4 lst) AG (nth 5 lst) PB (nth 6 lst) ZN (nth 7 lst) CU (nth 8 lst))
(setq romp (strcat X "," Y "," Z))
(setq YAU (- (atof Y) 0.5))
(setq Y2 (rtos YAU 2 4))
(setq rompAU (strcat X "," Y2 "," Z))
(setq YAG (- (atof Y) 1.0))
(setq Y3 (rtos YAG 2 4))
(setq rompAG (strcat X "," Y3 "," Z))
(setq YPB (- (atof Y) 1.5))
(setq Y4 (rtos YPB 2 4))
(setq rompPB (strcat X "," Y4 "," Z))
(setq YZN (- (atof Y) 2.0))
(setq Y5 (rtos YZN 2 4))
(setq rompZN (strcat X "," Y5 "," Z))
(setq YCU (- (atof Y) 2.5))
(setq Y6 (rtos YCU 2 4))
(setq rompCU (strcat X "," Y6 "," Z))
(setq AUtx (strcat "Au " AU))
(setq AGtx (strcat "Ag " AG))
(setq PBtx (strcat "Pb " PB))
(setq ZNtx (strcat "Zn " ZN))
(setq CUtx (strcat "Cu " CU))
(command "_point" romp)
(command "_Text" romp 0.5 0 ID)
(command "_Text" rompAU 0.3 0 AUtx)
(command "_Text" rompAG 0.3 0 AGtx)
(command "_Text" rompPB 0.3 0 PBtx)
(command "_Text" rompZN 0.3 0 ZNtx)
(command "_Text" rompCU 0.3 0 CUtx)
)
(princ)
)
我保留我正在使用的CSV文件。
**** Hidden Message *****
页:
[1]