넘버링 리습과 라인 리습을 합친건데요 마우스로 클릭할때마다 번호와 라인의 길이가 나오는 리습입니다. 근데 무엇이 잘못인지 화면상에서는 겹쳐서 나옵니다.
고수님들 부탁드립니다. 수정과 합께 어디가 잘못인지 지적해 주셨으면 합니다.
꼭 부탁드립니다.
;;===========================================================
; 선택된 Line의 길이을 모두 더하는 명령(000822cho_i)
; 각 선택한 개체에 번호와 길이를 한곳에 적는다. (2010/07/24)
;;———————————————————–
(defun c:tt(/ ss en n n1 k tot dis dis1 siz bas bas2 x1 y1 t1 text_out)
(prompt “nCommand: Line Plus…”)
; 글자크기 지정
;(setq siz (* 20 (getvar “dimscale”)))
(setq siz (getint “n글자크기를 지정해 주세요<1>: “))
(prompt “n더하고자하는 line을 선택-> “)
(setq ss (ssget))
(setq n1 (sslength ss))
(setq n n1 k 0)
(setq tot 0 dis 0 dis1 0)
(setq text_all “”)
(setq bas (getpoint “전체데이터 화면표시 위치:”))
(while (<= 1 n)
(setq en (ssname ss k))
(setq stype (cdr (assoc 0 (entget en))))
(if (= stype “LINE”)(progn
(setq spt (cdr (assoc 10 (entget en))))
(setq ept (cdr (assoc 11 (entget en))))
(setq dis1 (distance spt ept))
(setq dis (/ dis1 1000.0))(prin1 dis)
; Text Screen
(setq t1 (itoa (+ 1 k)))
(setq text_out (strcat t1 “) “))
(setq t1 (rtos dis 2 0))
(setq text_out (strcat text_out t1))
(setq x1 (car bas) y1 (cadr bas))
(setq y1 (- y1 (* siz (* 2 (+ 1 k)))))
(setq bas2 (list x1 y1))
(command “text” “s” “standard” bas2 siz 0 text_out)
))(terpri)
(if (= stype “LWPOLYLINE”)(progn
(command “area” “e” en)
(setq dis1 (getvar “perimeter”))
(setq dis (/ dis1 1000.0))
; Text Screen
(setq t1 (itoa (+ 1 k)))
(setq text_out (strcat t1 “) “))
(setq t1 (rtos dis 2 0))
(setq text_out (strcat text_out t1))
(setq x1 (car bas) y1 (cadr bas))
(setq y1 (- y1 (* siz (* 2 (+ 1 k)))))
(setq bas2 (list x1 y1))
(command “text” “s” “standard” bas2 siz 0 text_out)
))
(setq tot (+ tot dis))
(setq n (- n 1))
(setq k (+ k 1))
)(terpri)
(prompt “총”)(prin1 n1)(prompt “개의 라인…”)
(prompt “전체길이 : “)(prin1 tot)(prompt ” m”)
(prin1)
(setq text_out “Total Length: “)
(setq t1 (rtos tot 2 4)) ; 끝의숫자가 소숫점 자리수임 ( 0 ~ 4 가능 )
(setq text_out (strcat text_out t1))
(setq text_out (strcat text_out text_all))
; Text Screen
(setq x1 (car bas) y1 (cadr bas))
(setq y1 (+ y1 (* siz 2)))
(setq bas2 (list x1 y1))
(command “text” “s” “standard” bas2 siz 0 text_out)
)
참고로 저는 2011 캐드를 사용합니다.