编辑代码

*(format t "Hello world!     -  lisp.jsrun.net") 
(defun c:ZZ ()
    (setvar "osmode" 0)
    (princ "\n选取宗地线…")
    (setq plines (ssget (list (cons 0 "POLYLINE") (cons 8 "宗地线"))))
    (if (/= plines nil)
        (progn
            (setq count 0)
            (while (< count (sslength plines))
                (setq entnam1 (ssname plines count))
                (setq entnam (entget entnam1 '(" ")))
                (setq zbc ())
                (foreach gxz entnam
                    (if (= 10 (car gxz))
                        (setq zbc (cons (cdr gxz) zbc))
                    )
                )
                (setq zbc (reverse zbc))
                (setq dwdlst zbc
                      dwdnum 0
                      xx 0
                      yy 0
                )
                (while (/= dwdlst nil)
                    (setq ptl (car dwdlst))
                    (setq dwdlst (cdr dwdlst))
                    (setq dwdnum (+ 1 dwdnum))
                    (setq x (nth 0 ptl))
                    (setq y (nth 1 ptl))
                    (setq xx (+ x xx))
                    (setq yy (+ y yy))
                )
                (setq x (/ xx dwdnum))
                (setq y (/ yy dwdnum))
                (setq dwd (list x y))
                (command "text" "s" "宋体" "j" "m" dwd 1 0 (format "编号-%d" dwdnum))
                (setq count (+ 1 count))
            )
        )
    )
)