;;
;; 실명면적 "실명:1234.56m2" 을 "no \t 실명 \t 1234.56" 으로 csv 저장
;;
;; txts 실명면적 text 개체 저장
;; len 실명면적 개수
;; txt_lst txts 리스트의 n 번째 실명면적 개체 추출
;; txt txt_lst string 저장
;; rm_area_m2 "실명:1234.56m2" 에서 ":" >> "\t" "실명 \t 1234.56m2" 변환
;; n_rm_area 순번추가, m2삭제 "실명 \t 1234.56m2" 에서 "순번 \t 1234.56" 변환
;; txt_line write-line 으로 cav에 한줄 씩 출력 반복
;; "TOTAL AREA: 1234.56m2" 을 명령줄에 출력, 지정점에 결과값 삽입
;;
(defun c:CSV ( / pt1 txt_lst txts str rm_area_m2 rm_area n_rm_area len n style_ size_ csvfile file_w)
(setq _LISTXT ( ))
;
(prompt "\nSELECT TXTs: \n")
(setq txts (ssget "c" (setq pt1 (getpoint)) (getcorner pt1) '((0 . "text"))))
(setq len (sslength txts))
(setq n 0)
;
(setq csvfile "c:/temp/temp.csv")
(setq file_w (open csvfile "w"))
;
(setq _AREA 0.0)
(repeat len
(setq txt_lst (entget (ssname txts n)))
(setq str (cdr (assoc 1 txt_lst)))
;; Extract AREA from str
(setq loc_split (+ 3 (vl-string-search ":" str)))
(setq _AREA (+ _AREA
(atof (substr str loc_split (- (strlen str) (+ loc_split 1))))))
;;
(setq rm_area_m2 (vl-string-subst "\t" ":" str))
(setq rm_area (vl-string-subst "" "m2" rm_area_m2))
(setq n_rm_area (strcat (itoa n) "\t" rm_area))
(write-line n_rm_area file_w)
(setq n (1+ n))
);repeat
(setq style_ (cdr (assoc 7 (entget (ssname txts 0)))))
(setq size_ (cdr (assoc 40 (entget (ssname txts 0)))))
(princ (setq _TOTAL (strcat "\n" (getvar "CLAYER") "_TOTAL AREA: " (rtos _AREA 2 2) "m2\n")))
(prompt "\n>> Specify Insertion point of the Total Area...\n")
(entmake (list (cons 0 "TEXT") (cons 1 _TOTAL) (cons 7 style_) (cons 10 (getpoint)) (cons 40 size_)))
(princ _AREA)
;
(close file_w)
(princ "\n")
(princ)
);defun
'autocad' 카테고리의 다른 글
Automatically Number (0) | 2021.09.09 |
---|---|
Table2CSV (0) | 2021.09.08 |
Room Area (0) | 2021.09.06 |
\n (0) | 2021.09.01 |
Getvar "osnapmode" (0) | 2021.08.31 |