- (vl-load-com)
- (defun c:tt (/ 0text ent entdat i1 lm-str2num p p2 plst px py s ss txt x1 y1)
- (defun lm-Str2num (String / positioni YPOutString)
- (setq positioni -1 aiilst'() jci 0)
- (repeat (strlen string)
- (setq ascm(vl-string-elt string (setq positioni (+ positioni 1))))
- (if(< 47 ascm 58)
- (setq aiilst(append aiilst (list ascm)))
- (setq jci (1+ jci))
- )
- )
- (atoi(car(mapcar'VL-LIST->STRING(reverse (list aiilst)))))
- )
- (if (null _0text) (setq _0text "前缀"))
- (setq 0Text (Getstring (Strcat "\n请输入前缀<" _0Text ">:")))
- (if (= 0text "") (setq 0text _0text) (setq _0text 0text))
- ;选择需要的编号文字
- (prompt "请选择需要编号的文字")
- (setq ss (ssget '((0 . "text"))) i1 -1 plst nil)
- (while (setq ent (ssname ss (setq i1 (1+ i1))))
- (setq plst (cons (list ent(cdr(assoc 10 (entget ent)))) plst)) )
- ;定义编号顺序
- (setq plst (vl-sort plst '(lambda (x y) (< (fix(/(car (cadr x))10)) (fix(/(car (cadr y))10))))))
- (setq plst (vl-sort plst '(lambda (x y) (> (fix(/(cadr (cadr x))10)) (fix(/(cadr (cadr y))10))))))
- ;List表
- (setq i1 -1)
- (repeat (length plst)
- (setq ent (car (nth (setq i1 (1+ i1)) plst)))
- (setq entdat (entget ent))
- ;文本插入坐标
- (setq
- p (cdr (assoc 11 entdat)) ;文本基点坐标
- px (car p)
- py (car (cdr p))
- x1 (+ px 10.0)
- y1 (+ py -7.0)
- p2 (list x1 y1)
- S(lm-Str2num (cdr (assoc 1 entdat)))
- )
- (setq txt (strcat 0Text "-" (rtos S)))
- ;建立单行文字
- (entmake (list '(0 . "TEXT") ;建立单行文字
- (cons 1 txt) ;内容
- (cons 41 0.75) ;宽度因子
- (cons 72 1) ;水平对正样式
- (cons 73 2) ;垂直对正样式
- (cons 10 p2) ;坐标x
- (cons 11 p2) ;坐标y
- (cons 40 5.0) ;高度
- )
- )
- (entmake)
- )
- (prompt (strcat "\n本次共修改:" (rtos (+ 1 i1) 2 1) "个序号"))
- (princ)
- )
|