获取cad点坐标到xls代码
发布时间:2012-04-10 23:20:04
发布时间:2012-04-10 23:20:04
(defun setfile()
(setq f (getfiled "\n点坐标写入" "c:\\" "csv" 1))
(setq ff (open f "a"))
)
(defun setcon()
(initget "2 3")
(setq aa (getkword "请选择二维还是三维坐标(2):[2/3]"))
(cond
((= aa "2") (write-line "点编号,X坐标,Y坐标" ff))
((= aa "3") (write-line "点编号,X坐标,Y坐标,Z坐标" ff))
((= aa nil) (write-line "点编号,X坐标,Y坐标" ff))
)
)
(defun setpd()
(setq n 1)
(while (/= n nil)
(setq p1 (getpoint "\n请选择需要标注的点:"))
(if (= p1 nil)
(setq n nil)
(progn
(setq str2(strcat "pt" (rtos n 2 0)))
(setq n(+ 1 n))
(command ".text" p1 "" "" str2)
(setq x (rtos (car p1)2 4))
(setq y (rtos (cadr p1)2 4))
(setq z (rtos (caddr p1)2 4))
(cond
((= aa "2") (setq str1 (strcat str2 "," x "," y)))
((= aa "3") (setq str1 (strcat str2 "," x "," y "," z)) )
((= aa nil) (setq str1 (strcat str2 "," x "," y)))
)
(write-line str1 ff)
)
)
)
(close ff)
)
(defun c:wd ()
(setvar "cmdecho" 0)
(setfile)
(setcon)
(setpd)
(princ)
)