不解 ,出错的图如下 ;--- (defun c:aa ( / ss ssn ptlst ptmid enl) (setvar "cmdecho" 0) (princ "\n请选择一个矩形:") (setq ss (ssget ":E:S" '((0 . "LWPOLYLINE")) )) (setq ssn (ssname ss 0)) (setq ptlst (getplpts ssn)) (setq ptmid (mapcar '(lambda (x y) (/ (+ x y) 2.0)) (car ptlst) (caddr ptlst))) ;中点 (command "offset" "0.01" ssn ptmid "") (setq enl (entlast)) (setq ptlst (getplpts enl)) (entdel enl) (command "undo" "be") (command "trim" ssn "" "f" (car ptlst) (cadr ptlst)) (command "" "") (alert "1") (command "trim" ssn "" "f" (cadr ptlst) (caddr ptlst)) (command "" "") (alert "2") (command "trim" ssn "" "f" (caddr ptlst) (cadddr ptlst)) (command "" "") (alert "3") (command "trim" ssn "" "f" (cadddr ptlst) (car ptlst)) (command "" "") (alert "4") (command "undo" "e") (setvar "cmdecho" 1) (princ) ) ;--- ;;;************************************ ;;;返回polyline的点表 ;;;调用参数形式 ( 多义线图元名 ) ;;;************************************ (defun getplpts (pl / mark pts ver1 i ee pt) (if (= "POLYLINE" (cdr (assoc 0 (entget pl)))) (progn ; read points of ployline (setq mark "VERTEX" i 0 ver1 (entnext pl) ) (while (= "VERTEX" mark) (setq pts (append pts (list (cdr (assoc 10 (entget ver1)))))) (setq ver1 (entnext ver1) i (1+ i) ) (setq mark (cdr (assoc 0 (entget ver1)))) ) ) (progn ; read points of lwployline (setq ee (entget pl)) (foreach pt ee (if (= 10 (car pt)) (setq pts (append pts (list (append (cdr pt) (list (cdr (assoc 38 ee))))) ) ) ) ) ) ) pts ) ;;;
|