AutoCAD
치수선 값을 엑셀로 내보내기
skyground21
2021. 11. 9. 11:20
반응형
ttt.lsp
;; free lisp from cadviet.com
;;; this lisp was downloaded from http://www.cadviet.com/forum/topic/98743-nho-viet-lisp-xuat-text-tu-cad-sang-excel-dang-cot-theo-thu-tu-chon/
(defun LM:writecsv ( lst csv / des sep )
(if (setq des (open csv "w"))
(progn
(setq sep (cond ((vl-registry-read "HKEY_CURRENT_USER\\Control Panel\\International" "sList")) (",")))
(foreach row lst (write-line (LM:lst->csv row sep) des))
(close des)
t
)
)
)
(defun LM:lst->csv ( lst sep )
(if (cdr lst)
(strcat (LM:csv-addquotes (car lst) sep) sep (LM:lst->csv (cdr lst) sep))
(LM:csv-addquotes (car lst) sep)
)
)
(defun LM:csv-addquotes ( str sep / pos )
(cond
( (wcmatch str (strcat "*[`" sep "\"]*"))
(setq pos 0)
(while (setq pos (vl-string-position 34 str pos))
(setq str (vl-string-subst "\"\"" "\"" str pos)
pos (+ pos 2)
)
)
(strcat "\"" str "\"")
)
( str )
)
)
(defun C:ttt(/ lst ss i el x fn)
(setq lst (list) ss (ssget (list (cons 0 "TEXT"))) )
(repeat (setq i (sslength ss))
(setq x (ssname ss (setq i (1- i))))
(setq el (entget x))
(if (= (cdr (assoc 0 el)) "TEXT")
(setq lst (append lst (list (list (cdr (assoc 1 el))))))
)
)
(setq fn (vl-filename-mktemp nil nil ".csv"))
(if (and lst (LM:WriteCSV (reverse lst) fn))
(startapp "explorer" fn)
)
)
반응형