帮忙改一下文本前递增
首先感谢wxa123wl网友提供的源码,由于他的源码是框选后是从下到上递增的,我想改成从上到下递增,另外增加可以点选递增的方式,希望各位大神能帮我一下,谢谢!本帖最后由 xg2010 于 2020-10-30 15:01 编辑
谢谢大家。:D 感谢革天明老师的帮助,现将源码发出来,帮助更多的人,谢谢
(vl-load-com)
(defun C:YJ()
(setq sz (getint"输入起始整数: ")
szdz(getint"输入递增整数: ")
)
(if (null szdz)(setq szdz 1)) ;不输入递增数默认为1
(if (null sz)(setq sz 1)) ;不输入起始数默认为1
(while T
(setq ent (ssget ":S" (list (cons 0 "*text"))))
(setq stnm (ssname ent 0)
stnn (entget stnm)
contt(cdr(assoc 1 stnn))
szct (strcat (itoa sz)
(vl-string-left-trim " 0123456789" contt)
)
)
(entmod (subst(cons 1 szct)
(assoc 1 stnn)
stnn
)
)
(setq sz(+ sz szdz))
)
) (vl-load-com)
(defun C:YJ()
(setq sz (getint"输入起始整数: ")
szdz(getint"输入递增整数: ")
)
(if (null szdz)(setq szdz 1)) ;不输入递增数默认为1
(if (null sz)(setq sz 1)) ;不输入起始数默认为1
(while T
(setq ent (ssget ":S" (list (cons 0 "*text"))))
(setq stnm (ssname ent 0)
stnn (entget stnm)
contt(cdr(assoc 1 stnn))
szct (strcat (itoa sz)
(vl-string-left-trim " 0123456789" contt)
)
)
(entmod (subst(cons 1 szct)
(assoc 1 stnn)
stnn
)
)
(setq sz(+ sz szdz))
)
) (defun c:ttt()
(vl-load-com)
(setq sz (getint "\n输入起始整数: ")
szdz(getint "\n输入递增整数: ")
stn (ssget(list(cons 0 "*text")))
stnl(sslength stn)
n 0
reclist nil
)
(if (null szdz)(setq szdz 1)) ;不输入递增数默认为1
(if (null sz)(setq sz 1)) ;不输入起始数默认为1
(repeat stnl
(setq Stnm(ssname stn n)
inspnt(cdr(assoc 10 (entget stnm)))
reclist(cons (list (cadr inspnt) stnm) reclist)
)
(setqn(1+ n))
)
;Y排序
;(vl-sort reclist '(lambda(e1 e2)(<(cadr(car e1))(cadr(car e2)))))
(setqreclist(vl-sort reclist '(lambda(e1 e2)(>(car e1)(car e2))))) ;由下往上排序用 < 由上往下排序用 >
;递增
(setq n 0)
(foreach stna reclist
(setq stnm (cadr stna)
stnn (entget stnm)
contt(cdr(assoc 1 stnn))
szct (strcat (itoa sz)
(vl-string-left-trim " 0123456789" contt)
)
)
(entmod (subst(cons 1 szct)
(assoc 1 stnn)
stnn
)
);更新
(setq n(1+ n)sz(+ szdz sz))
)
)
已经修改,谢谢大家.
页:
[1]