本帖最后由 linshiyin2 于 2012-6-1 11:30 编辑
写了个重叠文字删除程序,但是运行有点慢,高手来改一下,实验过600个多行文字大概要20s。
- ;重叠的文字删除单行和多行
- ;判断方式为第一点,字高和文字内容相同
- (defun C:deladtxt (/ dxf1 dxf10 dxf101 dxf11 dxf40 dxf401 en en_data en1 k
- lis m n ss
- )
- (setq ss (ssget "x" '((-4 . "<OR") (0 . "TEXT")
- (0 . "MTEXT")
- (-4 . "OR>")
- )
- )
- )
- (setq n (- (sslength ss) 1)
- m 0
- k 0
- )
- (setq lis (ssadd))
- (repeat n
- (setq en (ssname ss 0))
- (setq en_data (entget en))
- (setq dxf10 (cdr (assoc 10 en_data))
- dxf40 (cdr (assoc 40 en_data))
- dxf1 (cdr (assoc 1 en_data))
- )
- (setq ss (ssdel en ss))
- (setq k (sslength ss))
- (repeat k
- (setq en1 (ssname ss m))
- (setq en_data (entget en1))
- (setq dxf101 (cdr (assoc 10 en_data))
- dxf401 (cdr (assoc 40 en_data))
- dxf11 (cdr (assoc 1 en_data))
- )
- (if (and
- (equal dxf10 dxf101)
- (equal dxf40 dxf401)
- (equal dxf1 dxf11)
- )
- (progn
- (setq lis (ssadd en1 lis))
- )
- )
- (setq m (+ m 1))
- )
- (setq m 0)
- )
- (setq m (sslength lis))
- (if (> m 0)
- (repeat m
- (setq en (ssname lis 0))
- (entdel en)
- (setq lis (ssdel en lis))
- )
- )
- (princ (strcat "删除文字个数:" (itoa m)))
- (princ)
- )
3楼加入了计算耗时。 |