attribute를 집계하는 리습인데..
집계장의 숫자(수량)가 정수로 나오거든요..
이걸 소숫점 두째자리까지 나오게 집계하려면 어떻해야하나요.
알려주시면 정말 감사하겠습니다.
vmon)
(defun *error* (s)
(setvar "cmdecho" 1)
(setvar "blipmode" 1)
(setvar "clayer" old_layer)
(setvar "filedia" 1)
(if (or (= s "quit / exit abort") (= s "console break"))
(princ (strcat "nError:" s))) ;if
(princ)
) ;defun error function
;—————————————————————————–
(defun StrToLst (at_lst / out_lst)
(setq out_lst (list (atoi (substr at_lst 1 1)) (substr at_lst 2 18)
(substr at_lst 20 20) (atoi (substr at_lst 41)))) ;setq
) ;defun sub function: Change string to list
;—————————————————————————–
(defun PlusLst (lst_a / lst_1 lst_2 lst_b lst_c out_lst)
(setq lst_1 (car lst_a)
lst_c nil)
(while lst_1
(setq lst_a (cdr lst_a)
lst_2 (car lst_a))
(while lst_2
(if (and (= (car lst_1) (car lst_2)) (= (cadr lst_1) (cadr lst_2)))
(setq lst_1 (subst (+ (last lst_1) (last lst_2)) (last lst_1) lst_1))
(setq lst_b (cons lst_2 lst_b)));if
(setq lst_a (cdr lst_a)
lst_2 (car lst_a))) ;while
(setq lst_c (cons lst_1 lst_c)
lst_a lst_b
lst_b nil
lst_1 (car lst_a))) ;while
(setq lst_a nil
out_lst lst_c)
) ;defun sub function: Plus list
;—————————————————————————–
(defun Sort (lst_d / flag_1 flag_2 num_1 num_2 l_s l_t temp c_1_1 c_1_2 c_1_3
c_1_4 c_1_5 c_1_6 c_2_1 c_2_2 c_2_3 c_2_4 c_2_5 c_2_6
lst_e lst_f out_lst)
(setq num_1 (length lst_d)
flag_1 T)
(while flag_1
(setq flag_2 T)
(while flag_2
(setq num_2 1
l_s (nth 0 lst_d)
temp l_s)
(repeat (- num_1 1)
(setq l_t (nth num_2 lst_d)
c_1_1 (substr (car l_s) 100 200)
c_1_2 (substr (car l_s) 300 200)
c_1_3 (substr (cadr l_s) 200 100)
c_1_4 (substr (cadr l_s) 400 100)
c_2_1 (substr (car l_t) 100 200)
c_2_2 (substr (car l_t) 300 200)
c_2_3 (substr (cadr l_t) 200 100)
c_2_4 (substr (cadr l_t) 400 100)) ;setq
(if (= (substr (cadr l_s) 800 100) ".")
(progn (setq c_1_5 (substr (cadr l_s) 700 100)
c_1_6 (substr (cadr l_s) 900 100)))
(setq c_1_5 (substr (cadr l_s) 700 200))) ;if
(if (= (substr (cadr l_t) 800 100) ".")
(progn (setq c_2_5 (substr (cadr l_t) 700 100)
c_2_6 (substr (cadr l_t) 900 100)))
(setq c_2_5 (substr (cadr l_t) 700 200))) ;if
(cond ((> c_1_1 c_2_1) (setq l_s l_t))
((= c_1_1 c_2_1)
(cond ((> c_1_2 c_2_2) (setq l_s l_t))
((= c_1_2 c_2_2)
(cond ((> c_1_3 c_2_3) (setq l_s l_t))
((= c_1_3 c_2_3)
(cond ((> c_1_4 c_2_4) (setq l_s l_t))
((= c_1_4 c_2_4)
(cond ((> c_1_5 c_2_5) (setq l_s l_t))
((= c_1_5 c_2_5)
(if (> c_1_6 c_2_6) (setq l_s l_t)))))))))))) ;cond
(setq num_2 (+ num_2 1))) ;repeat
(if (= l_s temp)
(progn (setq lst_e (cons l_s lst_e)
lst_d (cdr lst_d)
flag_2 nil
num_1 (- num_1 1)))
(setq lst_d (reverse (cons temp (reverse (cdr lst_d)))))) ;if
) ;while
(if (= num_1 1)
(progn (setq flag_1 nil
lst_e (reverse (cons lst_d lst_e))))) ;if
) ;while
(setq lst_f (car (car (reverse lst_e)))
out_lst (reverse (cons lst_f (cdr (reverse lst_e))))) ;setq
) ;defun sub function: Sort list
;—————————————————————————–
(defun ChgPt (in_pt x y / outpt_x outpt_y out_pt)
(setq outpt_x (+ (car in_pt) x)
outpt_y (+ (cadr in_pt) y)
out_pt nil
out_pt (cons outpt_y out_pt)
out_pt (cons outpt_x out_pt)) ;setq
) ;defun sub punction: Change point
;—————————————————————————–
(defun h_line (base_pt row_num / out_pt)
(repeat row_num
(command "line" base_pt "@13.5<0" "")
(setq base_pt (chgpt base_pt 0 -0.7))) ;repeat
(setq base_pt (chgpt base_pt -2 0))
(command "line" base_pt "@15.5<0" "")
(setq out_pt (chgpt base_pt 2 -0.7))
) ;defun sub function: draw horizontal line
;—————————————————————————–
(defun SubTotal (lst_g / subtt outtt)
(setq subtt 0)
(repeat (length lst_g)
(setq subtt (+ subtt (last (car lst_g)))
lst_g (cdr lst_g))) ;repeat
(setq outtt subtt)
) ;defun sub function: calculating sub total
;—————————————————————————–
(defun WSheet (label pt_t lst_h ttotal / rec_1 tname tsize tqty)
(command "text" pt_t "" "" label)
(setq pt_t (chgpt pt_t 2.1 0))
(repeat (length lst_h)
(setq rec_1 (car lst_h)
lst_h (cdr lst_h)
tname (car rec_1)
tsize (cadr rec_1)
tqty (itoa (last rec_1))) ;setq
(command "text" pt_t "" "" tname)
(command "text" (chgpt pt_t 3.55 0) "" "" tsize)
(if (= label "초화류")
(command "text" "c" (chgpt pt_t 8.7 0) "" "" "본")
(command "text" "c" (chgpt pt_t 8.7 0) "" "" "주"))
(command "text" "r" (chgpt pt_t 11.05 0) "" "" tqty)
(setq pt_t (chgpt pt_t 0 -0.7))) ;repeat
(command "text" pt_t "" "" "소 계")
(if (= label "초화류")
(command "text" "c" (chgpt pt_t 8.7 0) "" "" "본")
(command "text" "c" (chgpt pt_t 8.7 0) "" "" "주"))
(setq ttotal (itoa ttotal))
(command "text" "r" (chgpt pt_t 11.05 0) "" "" ttotal)
) ;defun sub function: write sheet and sub total
;—————————————————————————–
(defun c:sheet (/ old_layer f_name fn_old var_fname sour_lst line_file tree_lst
flag one_line flag_item con_lst brleaf_lst shrub1_lst shrub2_lst
pt_o row_con row_brleaf row_shrub1 row_shrub2 row_total lawn
lawn_l ver_len move_pt next_pt text_pt subtt_1 subtt_2 subtt_3
subtt_4 tt_1 tt_2)
(prompt "n작업 진행중 입니다! 잠시 기다리시요…")
(setvar "cmdecho" 0)
(setvar "blipmode" 0)
(setvar "filedia" 0)
(setvar "osmode" 0)
; Define text style
(if (= (tblsearch "style" "tree") nil)
(command "style" "tree" "romans,ghs" "" "" "" "" ""))
(setvar "textstyle" "tree")
(setvar "textsize" 0.3)
; Layer control
(setq old_layer (getvar "clayer"))
(if (= (tblsearch "layer" "-table") nil)
(command "layer" "m" "-table" "c" "3" "" "")
(if (/= old_layer "-table")
(setvar "clayer" "-table")))
; Define out_put file name
(setq f_name (strcat (getvar "dwgname") ".TXT"))
(if (findfile f_name)
(progn (prompt "n집계표 작성을 위한 출력파일 ")
(princ f_name)
(setq fn_old f_name
f_name (getstring "와 같은 이름의 파일이 존재합니다. n새로운 파일명은? (Enter=>Overwrite): "))
(if (= f_name "") (setq f_name fn_old))))
; Out_put atribute list to file and make source list by read file
(if (= (tblsearch "layer" "-attrib") nil)
(progn (prompt "n현재 배식된 사항이 없습니다.")
(quit))) ;if
(terpri)
(command "attext" "s" "tr-temp.txt" f_name)
(if (= f_name nil) (quit))
(setq var_fname (open f_name "r"))
(while (setq line_file (read-line var_fname))
(setq sour_lst (cons line_file sour_lst))) ;while
(close var_fname)
(setq tree_lst sour_lst)
; Sort by tree form and add equal item
(setq flag T)
(while flag
(setq one_line (if (/= (car tree_lst) nil) (StrToLst (car tree_lst)))
flag_item (car one_line)
tree_lst (cdr tree_lst)) ;setq
(cond ((= flag_item nil) (setq flag nil))
((= flag_item 1) (setq con_lst (cons (cdr one_line) con_lst)))
((= flag_item 2) (setq brleaf_lst (cons (cdr one_line) brleaf_lst)))
((= flag_item 3) (setq shrub1_lst (cons (cdr one_line) shrub1_lst)))
((= flag_item 4) (setq shrub2_lst (cons (cdr one_line) shrub2_lst)))
((= flag_item 5) (setq herb_lst (cons (cdr one_line) herb_lst))))) ; while
(setq con_lst (pluslst con_lst)
brleaf_lst (pluslst brleaf_lst)
shrub1_lst (pluslst shrub1_lst)
shrub2_lst (pluslst shrub2_lst)
herb_lst (pluslst herb_lst)) ;setq
; Make final list
(if (/= con_lst nil)
(if (= (length con_lst) 1)
(setq con_lst con_lst)
(setq con_lst (sort con_lst))))
(if (/= brleaf_lst nil)
(if (= (length brleaf_lst) 1)
(setq brleaf_lst brleaf_lst)
(setq brleaf_lst (sort brleaf_lst))))
(if (/= shrub1_lst nil)
(if (= (length shrub1_lst) 1)
(setq shrub1_lst shrub1_lst)
(setq shrub1_lst (sort shrub1_lst))))
(if (/= shrub2_lst nil)
(if (= (length shrub2_lst) 1)
(setq shrub2_lst shrub2_lst)
(setq shrub2_lst (sort shrub2_lst))))
(if (/= herb_lst nil)
(if (= (length herb_lst) 1)
(setq herb_lst herb_lst)
(setq herb_lst (sort herb_lst))))
; Drawing sheet table
(initget 1)
(setq pt_o (getpoint "n집계표의 좌측상단점을 찍으시요: ")
row_con (length con_lst)
row_brleaf (length brleaf_lst)
row_shrub1 (length shrub1_lst)
row_shrub2 (length shrub2_lst)
row_herb (length herb_lst)
row_total (+ row_con row_brleaf row_shrub1 row_shrub2 row_herb)) ;setq
(initget 0)
(setq flag T)
(while flag
(setq lawn (getint "n선택 잔디항목n<0>필요 없음, <1>평떼, <2>줄떼, <3>평떼 및 줄떼: "))
(if (and (>= lawn 0) (<= lawn 3))
(progn (setq flag nil)
(cond ((= lawn 0) (setq lawn_l 0))
((= lawn 1) (setq lawn_l 1))
((= lawn 2) (setq lawn_l 1))
((= lawn 3) (setq lawn_l 2)))) ;cond,progn
(Prompt "n잘못된 수치가 입력 되었음 (가능수치: 0-3) 재입력 하시오!"))) ;if,while
(setq ver_len (* -1 (+ 1 (* 0.7 row_total) (if (/= lawn_l nil) (* 0.7 lawn_l)))))
(if (/= row_con 0) (setq ver_len (- ver_len 0.7)))
(if (/= row_brleaf 0) (setq ver_len (- ver_len 0.7)))
(if (/= row_shrub1 0) (setq ver_len (- ver_len 0.7)))
(if (/= row_shrub2 0) (setq ver_len (- ver_len 0.7)))
(if (/= row_herb 0) (setq ver_len (- ver_len 0.7)))
(if (or (/= row_con 0) (/= row_brleaf 0)) (setq ver_len (- ver_len 0.7)))
(if (or (/= row_shrub1 0) (/= row_shrub2 0)) (setq ver_len (- ver_len 0.7)))
(command "line" pt_o "@15.5<0" "")
(command "line" (chgpt pt_o 0 -0.9) "@15.5<0" "")
(command "line" (chgpt pt_o 0 -1) "@15.5<0" "")
(command "line" pt_o (chgpt pt_o 0 ver_len) "")
(command "line" (chgpt pt_o 2 0) (chgpt pt_o 2 ver_len) "")
(command "line" (chgpt pt_o 5.7 0) (chgpt pt_o 5.7 ver_len) "")
(command "line" (chgpt pt_o 10.5 0) (chgpt pt_o 10.5 ver_len) "")
(command "line" (chgpt pt_o 11.5 0) (chgpt pt_o 11.5 ver_len) "")
(command "line" (chgpt pt_o 13.5 0) (chgpt pt_o 13.5 ver_len) "")
(command "line" (chgpt pt_o 15.5 0) (chgpt pt_o 15.5 ver_len) "")
(command "text" "c" (chgpt pt_o 1 -0.7) "" "" "성 상")
(command "text" "c" (chgpt pt_o 3.85 -0.7) "" "" "수 목 명")
(command "text" "c" (chgpt pt_o 8.1 -0.7) "" "" "규 격")
(command "text" "c" (chgpt pt_o 11 -0.7) "" "" "단위")
(command "text" "c" (chgpt pt_o 12.5 -0.7) "" "" "수 량")
(command "text" "c" (chgpt pt_o 14.5 -0.7) "" "" "비 고")
(setq text_pt (chgpt pt_o 0.2 -1.55)
next_pt (chgpt text_pt 1.8 -0.15))
(if (/= row_con 0)
(progn (setq move_pt (chgpt pt_o 2 -1.7)
next_pt (h_line move_pt row_con)
subtt_1 (subtotal con_lst)) ;setq
(wsheet "상록교목" text_pt con_lst subtt_1)
(setq text_pt (chgpt text_pt 0 (* (+ row_con 1) -0.7)))) ;progn
(setq text_pt (chgpt pt_o 0.2 -1.55))) ;if
(if (/= row_brleaf 0)
(progn (setq move_pt next_pt
next_pt (h_line move_pt row_brleaf)
subtt_2 (subtotal brleaf_lst)) ;setq
(wsheet "낙엽교목" text_pt brleaf_lst subtt_2)
(setq text_pt (chgpt text_pt 0 (* (+ row_brleaf 1) -0.7)))) ;progn
(setq text_pt text_pt)) ;if
(if (= subtt_1 nil) (setq subtt_1 0))
(if (= subtt_2 nil) (setq subtt_2 0))
(if (or (/= row_con 0) (/= row_brleaf 0))
(progn (command "line" (chgpt next_pt -2 0) "@15.5<0" "")
(setq next_pt (chgpt next_pt 0 -0.7)
tt_1 (+ subtt_1 subtt_2))
(command "text" text_pt "" "" "교목계")
(command "text" "c" (chgpt text_pt 10.8 0) "" "" "주")
(command "text" "r" (chgpt text_pt 13.15 0) "" "" (itoa tt_1))
(setq text_pt (chgpt text_pt 0 -0.7)))) ;progn,if
(if (/= row_shrub1 0)
(progn (setq move_pt next_pt
next_pt (h_line move_pt row_shrub1)
subtt_3 (subtotal shrub1_lst))
(wsheet "상록관목" text_pt shrub1_lst subtt_3)
(setq text_pt (chgpt text_pt 0 (* (+ row_shrub1 1) -0.7))))) ;progn,if
(if (/= row_shrub2 0)
(progn (setq move_pt next_pt
next_pt (h_line move_pt row_shrub2)
subtt_4 (subtotal shrub2_lst))
(wsheet "낙엽관목" text_pt shrub2_lst subtt_4)
(setq text_pt (chgpt text_pt 0 (* (+ row_shrub2 1) -0.7))))) ;if
(if (= subtt_3 nil) (setq subtt_3 0))
(if (= subtt_4 nil) (setq subtt_4 0))
(if (or (/= row_shrub1 0) (/= row_shrub2 0))
(progn (command "line" (chgpt next_pt -2 0) "@15.5<0" "")
(setq next_pt (chgpt next_pt 0 -0.7)
tt_2 (+ subtt_3 subtt_4))
(command "text" text_pt "" "" "관목계")
(command "text" "c" (chgpt text_pt 10.8 0) "" "" "주")
(command "text" "r" (chgpt text_pt 13.15 0) "" "" (itoa tt_2))
(setq text_pt (chgpt text_pt 0 -0.7)))) ;progn,if
(if (/= row_herb 0)
(progn (setq move_pt next_pt
next_pt (h_line move_pt row_herb)
subtt_5 (subtotal herb_lst))
(wsheet "초화류" text_pt herb_lst subtt_5)
(setq text_pt (chgpt text_pt 0 (* (+ row_herb 1) -0.7))))) ;progn,if
(if (/= lawn_l 0)
(if (= lawn_l 2)
(progn (command "line" next_pt "@13.5<0" "")
(setq next_pt (chgpt next_pt -2 -0.7))
(command "line" next_pt "@15.5<0" "")) ;progn
(command "line" (chgpt next_pt -2 0) "@15.5<0" ""))) ;if,if
(cond ((= lawn 1) (command "text" text_pt "" "" "지피")
(command "text" (chgpt text_pt 2.1 0) "" "" "잔디(평떼)")
(command "text" (chgpt text_pt 5.65 0) "" "" "0.3 x 0.3 x 0.03")
(command "text" "c" (chgpt text_pt 10.8 0) "" "" "M2")
(command "text" "r" (chgpt text_pt 13.15 0) "" "" "0"))
((= lawn 2) (command "text" text_pt "" "" "지피")
(command "text" (chgpt text_pt 2.1 0) "" "" "잔디(줄떼)")
(command "text" (chgpt text_pt 5.65 0) "" "" "0.3 x 0.3 x 0.03")
(command "text" "c" (chgpt text_pt 10.8 0) "" "" "M2")
(command "text" "r" (chgpt text_pt 13.15 0) "" "" "0"))
((= lawn 3) (command "text" text_pt "" "" "지피")
(command "text" (chgpt text_pt 2.1 0) "" "" "잔디(평떼)")
(command "text" (chgpt text_pt 5.65 0) "" "" "0.3 x 0.3 x 0.03")
(command "text" "c" (chgpt text_pt 10.8 0) "" "" "M2")
(command "text" "r" (chgpt text_pt 13.15 0) "" "" "0")
(setq text_pt (chgpt text_pt 0 -0.7))
(command "text" (chgpt text_pt 2.1 0) "" "" "잔디(줄떼)")
(command "text" (chgpt text_pt 5.65 0) "" "" "0.3 x 0.3 x 0.03")
(command "text" "c" (chgpt text_pt 10.8 0) "" "" "M2")
(command "text" "r" (chgpt text_pt 13.15 0) "" "" "0"))) ;cond
; Return system variables
(if (/= old_layer "sheet")
(setvar "clayer" old_layer))
(setvar "cmdecho" 1)
(setvar "filedia" 1)
(setvar "blipmode" 1)
(princ)
)
;defun main function