把lockmyeye的程序参考进去了,不敢独享,贴上来供诸位高手拍砖
;DDL: Copyright By WWZ,2003-12-3 ;颠倒直线的两端点,即交换实体对象组代码10和11, ;用于解决直线、dimension、多段线的线型换向问题 (defun C:ddl(/ tmp ed ent m n endpt1 endpt2 newline name) (princ "\n交换直线、多段线或标注的起点和终点.请选择直线、多段线或标注:\n") ;选择直线或标注,注意逻辑组的使用 (setq tmp (ssget (list (cons -4 " (if tmp (progn (setq n (sslength tmp) m 0) (repeat n (setq ent (ssname tmp m)) (setq ed (entget ent)) ;(ts "\nent=") ;(ts ent) (setq name (cdr (assoc 0 ed))) (if (= name "LWPOLYLINE") (lwpolyline_reverse ent ed) (progn (setq endpt1 (cons 11 (cdr (assoc 10 ed) ))) (setq endpt2 (cons 10 (cdr (assoc 11 ed) ))) (setq ed (subst endpt1 (assoc 11 ed) ed)) (setq ed (subst endpt2 (assoc 10 ed) ed)) (setq newline ed) ;删除原对象并生成相同句柄的新对象,注意: ;enddel 对象名称ent不是对象数据表ed ;endmod entmake 的不是对象名称ent是对象数据表ed (entdel ent) (entmake newline) ) );end if (setq m (1+ m)) );end repeat ) );end if tmp (princ "\n共处理了") (if m (princ m) (princ "0")) (princ "条直线(多段线、标注)。") (princ) );end C:ddl ;--------------------------------------------------------------------------- ;多段线的换向程序,修改自明经通道 (DEFUN lwpolyline_reverse (lwpent data / num data one points tempnum tempent) (SETQ points nil) (FOREACH one data (PROGN (IF (= (CAR one) 10) (SETQ points (APPEND points (LIST one))) ) ) ) (SETQ points (REVERSE points)) (SETQ tempnum 0) (SETQ tempent nil) (FOREACH one data (PROGN (IF (= (CAR one) 10) (SETQ tempent (APPEND tempent (LIST (NTH tempnum points))) tempnum (1+ tempnum) ) (SETQ tempent (APPEND tempent (LIST one))) ) ) ) (entdel lwpent) (entmake tempent) (PRINC) );end lwpolyline_reverse
|