先把坐标转成TXT格式如66877.042,127908.552
66879.097,127870.924
66879.481,127862.859然后(DEFUN C:ZK( / FN FI LL I0 II LE X Y ZC)
(SETVAR "CMDECHO" 0)
(SETVAR "OSMODE" 0);关闭捕捉
(SETQ FN (GETSTRING "请输入文件名<*.TXT>: "))
(SETQ FI (OPEN FN "R"));打开文件
(COMMAND "_.UNDO" "_BE")
(SETQ LL (READ-LINE FI))
(WHILE LL
(SETQ I0 1 II 1 ZC (SUBSTR LL 1 1))
(FLZ);取出一个字段的长度
(SETQ X (ATOF (SUBSTR LL I0 LE)));读取X坐标
(FLZ)
(SETQ Y (ATOF (SUBSTR LL I0 LE)));读取Y坐标
(FLZ)
(COMMAND "_INSERT" "C:\\我的块.DWG" (LIST Y X 0) 1 1 0 )
(SETQ LL (READ-LINE FI))
)
(CLOSE FI)
(COMMAND "_.UNDO" "_E")
(PRINC)
);END DEFUN(DEFUN FLZ()
(SETQ I0 II)
(WHILE (= ZC ",")
(SETQ I0 (1+ I0))
(SETQ ZC (SUBSTR LL I0 1))
);END WHILE
(SETQ II I0)
(WHILE (> ZC ",")
(SETQ II (1+ II))
(SETQ ZC (SUBSTR LL II 1))
)
(SETQ LE (- II I0))
);END DEFUN