CAD版本不同,有些命令不一样。
- (defun c:cdx ()
- (setvar "cmdecho" 0)
- (princ "\n选择方框<空格退出>:")
- (while (setq ss (ssget ":e:s" (list (cons 0 "lwpolyline"))))
- (setq lin (ssname ss 0) data (entget lin) pts nil)
- (foreach xx data (if (= 10 (car xx))(setq pts (cons (cdr xx) pts))))
- (command ".zoom" "W" (car pts) (caddr pts))
- (setq ens (ssget "cp" pts '((0 . "TEXT") (8 . "E-PE,e-id"))))
- (command ".zoom" "p")
- (or ens (setq ens (ssadd)))
- (setq len (sslength ens) n 0 strs nil)
- (while (< n len)
- (setq en (ssname ens n) data (entget en))
- (setq strs (cons (cons (cdr (assoc 10 data))(strcat " " (cdr (assoc 1 data)))) strs))
- (setq n (1+ n))
- )
- (if strs (progn
- (setq strs (vl-sort strs '(lambda(e1 e2) (> (cadar e1)(cadar e2)))))
- (setq str "")
- (foreach xx strs (setq str (strcat str (cdr xx))))
- (initget 1)
- (setq pt-ins (getpoint "\n指定一点:"))
- (entmake
- (list
- '(0 . "TEXT")
- '(100 . "AcDbEntity")
- '(8 . "E-PE")
- '(62 . 110)
- '(100 . "AcDbText")
- (cons 10 pt-ins)
- '(40 . 444.444)
- (cons 1 str)
- '(41 . 0.7)
- '(7 . "HZ")
- )
- )
- )
- (princ "\n不包含指定层文字!")
- )
- (princ "\n选择方框<空格退出>:")
- )
- (setvar "cmdecho" 1)
- (princ)
- )
|