NC데이타를 캐드에서 불러오면 선으로 나와야되는데
치수대로 안나오고 깨져서 나옵니다.
조금만 손보면 될것같은데 리습은 아는게 없어서…
고수분께서 수정해주시면 고맙겠습니다.
(defun c:nc( ) ;NC DATA 를 선(LINE)으로 표현 시켜준다.
(setvar “cmdecho” 0)
(setq data_file (getfiled “NC DATA 화일을 선택” “” “*” 0))
(SETQ file (open data_file “r”))
(setq p “”)
(SETQ Pold (LIST 0 0))
(setq txtxold “”)
(setq txtyold “”)
(setq txtzold “”)
(setq count 0)
(command “osmode” 16423)
(while (/= p nil)
(setq p (read-line file))
(if (/= p nil)
(progn
(setq n 1)
(setq xn 0)
(setq yn 0)
(setq zn 0 )
(setq txt “”)
(setq txty “”)
(setq txtz “”)
(setq paste 0)
(while (/= n 50)
(progn
(setq char (substr p n 1))
(if (= char “X”)
(setq paste 1)
)
(if (= char “Y”)
(setq paste 2)
)
(if (= char “Z”)
(setq paste 3)
)
(if (= paste 1)
(progn
(if (< 0 xn)
(if (/= char ” “)
(setq txt (strcat txt char))
)
)
(setq xn (+ 1 xn))
)
)
(if (= paste 2)
(progn
(if (< 0 yn)
(if (/= char ” “)
(setq txty (strcat txty char))
)
)
(setq yn (+ 1 yn))
)
)
(if (= paste 3)
(progn
(if (< 0 zn)
(if (/= char ” “)
(setq txtz (strcat txtz char))
)
)
(setq zn (+ 1 zn))
)
)
(setq n (+ 1 n))
(if (= n 50)
(progn
(if (/= txt “”)
(setq txtxold txt)
)
(if (/= txty “”)
(setq txtyold txty)
)
(if (/= txtz “”)
(setq txtzold txtz)
)
(setq txtxoldf (atof txtxold))
(setq txtyoldf (atof txtyold))
(setq txtzoldf (atof txtzold))
(SETQ P (LIST txtxoldf txtyoldf txtzoldf))
(setq count (+ 1 count))
(command “line” pold p “”)
(setq pold p)
))
)
)
)
)
)
(close file)
(princ count)
(PRINC ” line read! “)
(princ)
)