明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2299|回复: 2

请高手帮忙写个更改编号(自动相加工具)

[复制链接]
发表于 2014-2-22 10:38:21 | 显示全部楼层 |阅读模式
10明经币
本帖最后由 lxy_2080 于 2014-2-22 13:16 编辑

原编号:号码 china-001"2/22"  号码 china-001"1/33"  号码 china-001"1/22"  号码 china-001"3/22"  号码 china-001"5/22"  号码 china-001"2/22"  号码 china-001"2/22".
新编号:号码 china-001"1/22"   号码 china-001"2/22"  号码 china-001"3/22"   号码 china-001"4/22"  号码 china-001"5/22"  号码 china-001"6/22"  号码 china-001"7/22".

要求:新的编号刷时,只更改""""里面的数字,22是要求输入的数字,在新编号中不进行增减,1/2/3/4/等,要求输入下第一个数字,后面自动相加.(字体\字号保持原来不变)

最好能批量选取(更改顺序是从左至右、从上至下)及一个一个的选。

最佳答案

查看完整内容

(defun c:subno (/ ss no1 no2 entlst sortlst newno1 newno2) (defun Ss->Lst (ss) (vl-remove-if-not '(lambda (x) (= (type x) 'ENAME)) (apply 'append (ssnamex ss)) ) ) ;_选择集变表 (defun strcut (str / start asclst revstr end newlst i sumlen) (setq start (VL-STRING-SEARCH "\"" str)) (setq asclst (VL-STRING->LIST str)) (setq revstr (VL-LIST->STRING (REV ...
发表于 2014-2-22 10:38:22 | 显示全部楼层
本帖最后由 caiqs 于 2014-2-22 15:26 编辑
lxy_2080 发表于 2014-2-22 10:42
忘传附件了。哈哈。钱不多,表个心意。望高手给予帮助
(defun c:subno (/ ss no1 no2 entlst sortlst newno1 newno2)
  (defun Ss->Lst (ss)
    (vl-remove-if-not
      '(lambda (x) (= (type x) 'ENAME))
      (apply 'append (ssnamex ss))
    )
  ) ;_选择集变表

  (defun strcut        (str / start asclst revstr end newlst i sumlen)
    (setq start (VL-STRING-SEARCH "\"" str))
    (setq asclst (VL-STRING->LIST str))
    (setq revstr (VL-LIST->STRING (REVERSE asclst)))
    (setq sumlen (strlen str))
    (setq end (vl-string-search "\"" revstr))
    (setq end (- sumlen end))
    (setq newlst nil)
    (setq i start)
    (repeat (- end start)
      (setq newlst (cons (nth i asclst) newlst))
      (setq i (1+ i))
    )
    (VL-LIST->STRING (REVERSE newlst))
  ) ;_剪取双引号中的文字
  (while t
  (princ "\n选择文字:")
  (setq        ss (VL-CATCH-ALL-APPLY
             'ssget
             (list (list (cons 0 "*text") (cons 1 "*\"*/*\"*")))
           )
  )
  (if (or (null ss) (VL-CATCH-ALL-ERROR-P ss))
    (VL-EXIT-WITH-ERROR 0)
  )
  (initget 5)
  (setq NO1 (VL-CATCH-ALL-APPLY 'getint '("\n输入递增序号:")))
  (if (VL-CATCH-ALL-ERROR-P NO1)
    (progn (princ "*取消*") (VL-EXIT-WITH-ERROR 1))
  )
  (setq NO2 (VL-CATCH-ALL-APPLY 'getstring '("\n输入固定编号:")))
  (if (or (VL-CATCH-ALL-ERROR-P NO2)
          (= (strlen (vl-string-trim " " No2)) 0)
      )
    (progn (princ "*取消*") (VL-EXIT-WITH-ERROR 1))
  )
  (setq entlst (ss->lst ss))
  (setq
    sortlst (vl-sort
              entlst
              '(lambda
                 (txta txtb / txtadat txtbdat inspa inspb x1 x2 y1 y2)
                  (setq txtAdat (entget txta))
                  (setq txtbdat (entget txtb))
                  (setq inspA (cdr (assoc 10 txtadat)))
                  (setq inspb (cdr (assoc 10 txtbdat)))
                  (setq        x1 (car inspa)
                        x2 (car inspb)
                        y1 (cadr inspa)
                        y2 (cadr inspb)
                  )
                  (if (= x1 x2)
                    (<= Y1 y2)
                    (<= x1 x2)
                  )

               )
            )
  ) ;_按位置排序
  (setq newNO1 no1)
  (setq newNO2 NO2)
  (mapcar
    '(lambda (txt / txtdat txtstr newno willcutstr newstr newtxtdat)
       (setq txtdat (entget txt))
       (setq txtstr (cdr (assoc 1 txtdat)))
       (setq newNO (strcat "\"" (itoa newno1) "/" newNO2 "\""))
       (setq willcutstr (strcut txtstr))
       (setq newstr (vl-string-subst newno willcutstr txtstr))
       (setq newtxtdat (subst (cons 1 newstr) (assoc 1 txtdat) txtdat))
       (entmod newtxtdat)
       (entupd txt)
       (setq newNO1 (1+ newNo1)) ;_编号递增
     )
    sortlst
  ) ;_批量替换
    )
  (princ)
)

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
回复

使用道具 举报

 楼主| 发表于 2014-2-22 10:42:27 | 显示全部楼层
本帖最后由 lxy_2080 于 2014-2-22 10:57 编辑

忘传附件了。哈哈。钱不多,表个心意。望高手给予帮助

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2025-2-27 12:53 , Processed in 0.175586 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表