阙 02:05:13
(defun c:mgcd () ;高程注记自动移位
(setvar "cmdecho" 0)
(command "undo" "be")
(command "layer" "off" "assist,zdh" "")
(setvar "osmode" 0)
(setq n 0)
(setq xzj nil)
(setq xzj (ssget '((0 . "TEXT") (8 . "GCD"))))
(princ "\n 正在移动高程注记,请等待...")
(while xzj
(repeat (sslength xzj)
(setq ename (entget (ssname xzj n) '("*")))
(setq cord (assoc 10 ename))
(command "zoom" "c" (cdr cord) 30 )
(setq l (nth 0 (cadr (textbox ename))));获取字长
(setq h (cdr (assoc 40 ename)));获取字高
(setq dh1 (atof (rtos (nth 3 cord) 2 3)))
(setq ptx (atof (rtos (nth 1 cord) 2 3)))
(setq pty (atof (rtos (nth 2 cord) 2 3)))
(setq x (- ptx (* h 0.6)) y (+ pty (* h 0.6)) x0 (- ptx (* h 0.5)) y0 (+ pty (* h 0.5)) )
(setq ptx0 (+ ptx (* h 0.3)))
;如果高程注记已人为移动了,则不移动
(setq ssp (ssget "c" (list x0 y0) (list x y) '((0 . "INSERT") (8 . "GCD"))))
(if (/= ssp nil)
(progn
(setq ptx2 (+ ptx l) pty2 (+ pty h))
(setq sl (ssget "c" (list ptx0 pty) (list ptx2 pty2) '((0 . "INSERT,LWPOLYLINE,POLYLINE,LINE,CIRCLE"))))
(if (/= sl nil)
;第一次循环 |