原帖“根据南方CASS点号提取展点号坐标”中code代码另存为lsp文件,执行命令显示为字符串有缺陷。在此向大家请教有更好的方法谢谢分享
原code代码如下:
- (defun c:tt( / f ss lst ss m n e a ee b ptlst1 xx bb)
- (setq f(open(getfiled "打开(或建立)数据文件" "C:" "dat" 1)"w"))
- (setq ss(ssget"X"'((8 . "ZDH")(0 . "POINT,INSERT")(-3 ("NAME,CODE")))))
- (setq lst '())
- (setq bb "NAME,CODE, Y坐标,X坐标,高程\n")
- (if ss
- (progn(setq m 0
- n(sslength ss))
- (while(< m n)
- (setq e(entget(ssname ss m)'("*"))m(1+ m))
- (if (setq a(cdr(assoc -3 e)))
- (setq eE(cdr(assoc 10 e))
- b (LIST (atof (cdr (car (cdr (nth 0 a))))) (read (cdr (car (cdr (nth 1 a))))) (CAR EE) (CADR EE) (CADDR EE))
-
- )
- ) (SETQ LST (APPEND LST (LIST B)))
- );;;;;;;;;;;;;;;;;;;;;;
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (setq ptlst (vl-sort LST
- ;以下根据点号对表排序
- '(lambda (e1 e2)
- (<= (car e1) (car e2) )
- ) ) )
- ;;;;;;;;;;;;;;;;;-----------------------------------
- (foreach xx ptlst
- (setq bb(strcat bb(vl-princ-to-string (nth 0 xx))","(vl-princ-to-string (nth 1 xx))","(rtos (nth 2 xx) 2 3)"," (rtos (nth 3 xx) 2 3)","(rtos (nth 4 xx) 2 3)"\n"))
-
- )
-
- ))
- (write-line bb f)
- (close f)
- )
|