yxp 发表于 2009-8-20 01:15:00

[源码]字母与数字组合字符串的增量复制 -- 待完善

<p>(defun c:xcc (/ )<br/>(setq i 1)<br/>(setvar "cmdecho" 0)<br/>(if (setq ee (entsel "\n选择数字 &lt;退出&gt;: "))<br/>&nbsp; (progn<br/>&nbsp;&nbsp; (setq str (cdr (assoc 1 (entget (car ee))))&nbsp; ;;返回所选文字<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pt1 (cadr ee)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;;返回选择点,作为copy的第一点<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strs (substr str 1 (aa str))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;;截取非数字字符<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strn (substr str (+ (aa str) 1) (strlen str)))&nbsp;&nbsp;&nbsp; ;;截取数字字符<br/>&nbsp;&nbsp; (command "copy" ee "" "m" pt1 <br/>&nbsp;&nbsp; (while (progn <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (setq news (strcat strs (itoa (+ (atoi strn) i))))<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (setq i (+ 1 i) pt1 pt2)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (command pause)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;;暂停等待屏幕输入<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (setq pt2 (getvar "LASTPOINT"))&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;;获取输入点<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (setq e (entlast))<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (entmod (subst (cons 1 news)(assoc 1 (entget e))(entget&nbsp; e)))<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (princ news)(princ "\n选择数字 &lt;退出&gt;: ")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (not (eq pt1 pt2))<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )))<br/>&nbsp;&nbsp;&nbsp; )<br/>&nbsp; )<br/>&nbsp; (princ)<br/>)</p><p>;;返回数字在字符中的位置<br/>(defun aa(tr / n i m k)<br/>(setq n (strlen tr) i 0 k -1)<br/>(while (&lt; i n)<br/>&nbsp; (setq m (substr tr (- n i) 1))<br/>&nbsp; (if (/= (itoa (atoi m)) m) (setq k i i n))<br/>&nbsp; (setq i (+ i 1)))<br/>(- (strlen tr) (if (= k -1) i k))<br/>)</p>

5061220 发表于 2009-8-20 08:12:00

嘿嘿!好东西啊!向楼主学习

liminnet 发表于 2009-8-20 09:17:00

liminnet 发表于 2009-8-20 09:34:00

liminnet 发表于 2009-8-20 09:36:00

navsun 发表于 2009-8-20 09:44:00

什么行业能用的上这么大的数?楼上是做天文学的吗?

liminnet 发表于 2009-8-20 09:53:00

liminnet 发表于 2009-8-20 17:16:00

yxp 发表于 2009-8-20 17:22:00

<p><strong><font face="Verdana" color="#61b713">liminnet</font></strong>有功夫帮忙把一楼的代码完善一下啊,好像有点问题。</p>

liminnet 发表于 2009-8-20 17:40:00

页: [1]
查看完整版本: [源码]字母与数字组合字符串的增量复制 -- 待完善