- (defun c:fhcx ()
- (vl-load-com)
- (setvar "cmdecho" 0)
- (setq v1 (getvar "osmode"))
- (setvar "osmode" 0)
- (setq blc(getreal "请输入当前图形的比例尺<500>:"))
- (if (= b1 nil)
- (setq b1 500))
- (setq blxs (* 0.001 blc));新插入块的比例系数
- (setq xzl (- (* 0.02 blc) 1.5))
- (setq yzl (- (* 0.01 blc) 1.5))
- (setq s1 (entsel "\n请选择一个植被符号:"))
- (command "zoom" "e" "")
- (setq tyb (entget(car s1)));图元表
- (setq gjz0 (assoc 0 tyb));关键字0
- (setq tkm (assoc 2 tyb));图块名
- (setq tcm (assoc 8 tyb));图层名
- (setq glb (list gjz0 tcm tkm));选择集过滤表
- (setq s (ssget "x" glb ));植被选择集
- (setq tygs (sslength s));选择集内图元个数
- (setq ff (open "d:/坐标表.txt" "w"));新建植被插入点坐标文档
- (setq i 0)
- (repeat tygs
- (setq dgtym (ssname s i))
- (setq dgtyb (entget dgtym));单个符号图元表
- (setq zbb (cdr (assoc 10 dgtyb)));坐标表
- (setq zbx (rtos (car zbb) 2 2))
- (setq zby (rtos (cadr zbb) 2 2))
- (setq zbzfq (strcat zbx "," zby));坐标字符串
- (write-line zbzfq ff);写入坐标字符串
- (setq i (1+ i)))
- (close ff)
- (command "._erase" s "" );删除植被符号
- (setq tcm1 (cdr tcm))
- (command "layer" "s" tcm1 "");设置当前层
- (setq ff (open "d:/坐标表.txt" "r"));打开植被插入点坐标文档
- (setq tkmc (strcat (cdr tkm) ".dwg"))
- (setq i 0)
- (while (< i tygs)
- (setq zbzfq (read-line ff));读出坐标字符串
- (setq zfqcd (strlen zbzfq));坐标字符串的长度
- (setq dhwz (vl-string-search "," zbzfq));查找,所在位置
- (setq xzb (atof (substr zbzfq 1 dhwz)));截取字符串转换为X坐标
- (setq yzb (atof (substr zbzfq (+ dhwz 2))));截取字符串转换为y坐标
- (setq zbb (list xzb yzb));组合为坐标表
- (setq p1 (list (- xzb xzl) (- yzb yzl)));检查是否有植被符号的范围
- (setq p2 (list (+ xzb xzl) (+ yzb yzl)))
- (setq s (ssget "w" p1 p2 glb ));植被选择集
- (if (= s nil)
- (progn
- (setq p1 (list (- xzb 3) (- yzb 3 (* 0.01 blc))))
- (setq p2 (list (+ xzb 3) (+ yzb 3 (* 0.01 blc))))
- (setq s (ssget "w" p1 p2 glb ));植被选择集
- (if (= s nil)
- (command "-insert" tkmc zbb blxs blxs blxs))))
- (setq i (1+ i)))
- (close ff)
- (command "layer" "s" 0 "");设置当前层
- )
|