本帖最后由 yjr111 于 2011-10-31 22:21 编辑
源程序上传,没必要自己留着,就怕自己写得不好,所以不好意思拿出来。。。
- ;;;;;;;;;;;;;找出各组对应位置最大值 BY YJR111 2011-10-30;;;;;;;;;;;;;;;;;;;;;;;
- (DEFUN c:findmaxnum(/ nn mm ss n ss0 pt0 lst ssn ptn lst_1 lst_2 lst_3 lst_4 nth_n $dist);;;;;局部变量自己填吧,习惯还没改过来
-
- (vl-load-com)
- (setvar "cmdecho" 0)
- (if (SETQ SS (ssget '((0 . "*TEXT" ))))
- (progn
- (SETQ nn 1)
- (SETQ SS0(ENTGET (SSNAME SS 0)))
- (setq height (CDR(ASSOC 40 SS0)))
- (SETQ PT0(list (CDR(ASSOC 10 SS0))(CDR(ASSOC -1 SS0))))
- (SETQ LST_0 (LIST PT0))
- (REPEAT (-(SSLENGTH SS) 1)
- (SETQ SSN(ENTGET (SSNAME SS nn)))
- (SETQ PTN (list (CDR(ASSOC 10 SSN))(CDR(ASSOC -1 SSN))))
- (SETQ LST_0(REVERSE (APPEND(LIST PTN)(REVERSE LST_0))))
- (SETQ nn (1+ nn))
- )
- (princ"\n 共选中")(princ (sslength ss))(princ "个文本")
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;根据距离不同进行分组;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (setq txt_lst(vl-sort LST_0(function(lambda (x1 x2)
- (>(cadar x1) (cadar x2))))))
- (setq txt_lst1 (cdr txt_lst))
- (setq txt_lst2 (reverse(cdr(reverse txt_lst))))
-
- (setq lst_dist(vl-sort (mapcar (function (lambda(x y)(-(cadar x )(cadar y )))) txt_lst2 txt_lst1)'>))
- (setq lst_$dist1 (cdr lst_dist))
- (repeat (length lst_dist)
- (setq lst_dist11(vl-remove nil (mapcar (function (lambda(x y)(if (/= x y ) x ))) lst_dist lst_$dist1)))
- )
- (setq lst_dist (append lst_dist11 (list (last lst_dist))))
- (princ "\n 文字间距列表清单如下")
- (princ lst_dist )
- (initget 128 "Y N")
- (setq key (getkword "\n 是否需要重新确定各组间距?<Y> \n 或以程序默认的列表第一个间距值?(N)<右键默认>"))
-
- (if (not key)(setq key "N"))
- (if (= key "N")(progn
- (cond ((= (length lst_dist)1)
- (setq $dist (+(car lst_dist)1e-3)))
- ((= (length lst_dist)2)
- (setq $dist (car lst_dist)))
- ((> (length lst_dist)2)
- (setq $dist (cadr (reverse lst_dist))))
- )
|