 - ;; 查找出现次数最多表项】
- ;; 返回表中出现次数和元素
- ;; by chlh_jd 发表于 2012-7-18 20:01:02
- ;;;http://bbs.mjtd.com/forum.php?mod=redirect&goto=findpost&ptid=95639&pid=539700&fromuid=338795
- (defun vl-maxtimes (lst / a len ti new)
- (while lst
- (setq a(car lst)len(length lst)
- ti (- len (length (setq lst (vl-remove a lst))))
- new (cons (cons ti a) new)))
- ;(if new(car(vl-sort new (function (lambda (e1 e2) (> (car e1) (car e2)))))))
- )
- ;;;
- ;;;组码值提取(sk_dxf 图元名 组码)
- (defun sk_dxf(en code)
- (if(and(=(type en) 'ENAME)(= (type code) 'INT))
- (cdr(assoc code (entget en))))
- )
- ;;;单行文本重复统计
- ;;; editor by edata
- ;;; 2014-1-7 17:43:51
- (defun c:tt(/ EN K NEW_LST PT SS STR_LST)
- (or font_heigth (setq font_heigth 300))
- (if(setq ss(ssget'((0 . "text"))))
- (progn
- (setq str_lst '())
- (while (setq en(ssname ss 0))
- (setq str_lst(cons (sk_dxf en 1)str_lst))
- (setq ss(ssdel en ss))
- )
- (setq str_lst(reverse str_lst))
- (setq new_lst(vl-maxtimes str_lst))
- (if (and (not (null new_lst)) (setq k -1 pt(getpoint "\n指定放置位置点:")))
- (foreach n new_lst (entmakex (list
- (cons 0 "text")
- (cons 10 (polar pt (* pi 1.5) (* (setq k(1+ k)) (* font_heigth 1.5))))
- (cons 1 (strcat (cdr n)" " (rtos (car n) 2 0)))
- (cons 40 font_heigth)
- )
- ))
- )
- )
- (princ"\n Nothing Select Object!!!")
- )
- (princ)
- )
|