明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: 半听可乐

谁能帮我写改编号尾数的程序?

  [复制链接]
发表于 2012-9-25 15:41:03 | 显示全部楼层
这么个小程序对你来说应该不是什么难题啊,简单写了下,你自己调试再改下!
  1. (defun c:een()
  2. (setq n 0)
  3.   (if (setq ss (ssget '((0 . "text"))))
  4.       (repeat (sslength ss)
  5.          (setq txt-lst (entget (ssname ss n)))
  6.          (setq txt-str (cdr (assoc '1 txt-lst)))
  7.          (setq sec (substr txt-str (strlen txt-str)))
  8.          (setq firs (substr txt-str '1 (- (strlen txt-str) 1)))
  9.          (setq sec-i-str (itoa (+ (atoi sec) 1)))
  10.          (setq txt-str (strcat firs sec-i-str))
  11.          (setq txt-lst (subst (cons '1 txt-str) (assoc '1 txt-lst) txt-lst))
  12.          (entmod txt-lst)
  13.          (setq n (1+ n))
  14.       )
  15.   )
  16. (princ)
  17. )

点评

你这个是选择数据,然后数据递增,能不能增加递减选项呢?比如说程序运行后右键递增,空格递减?  发表于 2012-9-25 15:53

评分

参与人数 1明经币 +1 收起 理由
半听可乐 + 1 很给力!

查看全部评分

回复

使用道具 举报

 楼主| 发表于 2012-9-25 15:47:58 | 显示全部楼层
Andyhon 发表于 2012-9-25 15:31
(setq ss (ssget "X" '((0 . "TEXT") (1 . "*-#")))
  ===>
  (setq ss (ssget '((0 . "TEXT") (1 . "* ...

非常感谢!这样的功能真是太方便了!
回复

使用道具 举报

 楼主| 发表于 2012-9-25 15:50:10 | 显示全部楼层
Andyhon 发表于 2012-9-25 15:31
(setq ss (ssget "X" '((0 . "TEXT") (1 . "*-#")))
  ===>
  (setq ss (ssget '((0 . "TEXT") (1 . "* ...

为了方便其他朋友,我把完整程序附上,谢谢Andyhon长老!

;;;-------------------------------------------------------------------------------------------------------------------
;;; ★gws  改尾数
;;;   By  Andyhon
;;;-------------------------------------------------------------------------------------------------------------------
(defun C:gws()
(setq ss (ssget '((0 . "TEXT") (1 . "*#")))
       Num (getstring "\n新的编号: ")
        i  0
  )
  (while (setq ee (ssname ss i))
    (setq obj (vlax-ename->vla-object ee)
          txt (vla-get-textstring obj)
          txt (reverse (vl-string->list txt))
          txt (vl-list->string (reverse (cdr txt)))
          i   (1+ i)
    )
    (vla-put-textstring obj (strcat txt Num))
  )
)
回复

使用道具 举报

发表于 2012-9-25 17:39:06 | 显示全部楼层
哈哈,又长知识了!
回复

使用道具 举报

发表于 2012-9-26 13:04:47 | 显示全部楼层
;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
;试用
;递增1按+
;递减1按-
(defun een()
      (setq n 0)
      (repeat (sslength (ssget "P"))
         (setq txt-lst (entget (ssname ss n)))
         (setq txt-str (cdr (assoc '1 txt-lst)))
         (setq sec (substr txt-str (strlen txt-str)))
         (setq firs (substr txt-str '1 (- (strlen txt-str) 1)))
         (setq sec-i-str (itoa (+ (atoi sec) 1)))
         (setq txt-str (strcat firs sec-i-str))
         (setq txt-lst (subst (cons '1 txt-str) (assoc '1 txt-lst) txt-lst))
         (entmod txt-lst)
         (setq n (1+ n))
      )
(princ)
)
(defun eem()
      (setq n 0)
      (repeat (sslength (ssget "P"))
         (setq txt-lst (entget (ssname ss n)))
         (setq txt-str (cdr (assoc '1 txt-lst)))
         (setq sec (substr txt-str (strlen txt-str)))
         (setq firs (substr txt-str '1 (- (strlen txt-str) 1)))
         (setq sec-i-str (itoa (- (atoi sec) 1)))
         (setq txt-str (strcat firs sec-i-str))
         (setq txt-lst (subst (cons '1 txt-str) (assoc '1 txt-lst) txt-lst))
         (entmod txt-lst)
         (setq n (1+ n))
      )
(princ)
)
(vl-load-com)
(defun c:tt()
   (if(setq ss (ssget '((0 . "text"))))
    (repeat 88
     (if (and (=(car(grread))2)(= (cadr(grread))43))
         (een)
      )
     (if(and (=(car(grread))2)(= (cadr(grread))45))
        (eem)
      )
    )
  )
)
;
;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
;
回复

使用道具 举报

 楼主| 发表于 2012-9-26 17:01:15 | 显示全部楼层
crazylsp 发表于 2012-9-26 13:04
;_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
;试用
;递增1按+
...

不管用~没反应 的
回复

使用道具 举报

发表于 2012-9-26 17:47:12 | 显示全部楼层
多按几次就可以了。
回复

使用道具 举报

发表于 2012-9-28 21:53:26 | 显示全部楼层
本帖最后由 aaacjh 于 2012-9-28 21:54 编辑
crazylsp 发表于 2012-9-26 17:47
多按几次就可以了。


是诶,多按几次才有反应.思路学习前辈.请教前辈! getread 函数针对键盘输入(2),是否有个对于表可供查询?
回复

使用道具 举报

发表于 2012-9-28 22:09:12 | 显示全部楼层
半听可乐 发表于 2012-9-25 15:50
为了方便其他朋友,我把完整程序附上,谢谢Andyhon长老!

;;;-------------------------------------- ...

vla-get-textstring 像这种vla开头的是什么函数,请教!,在常规的帮助文件中查不到.
回复

使用道具 举报

发表于 2012-9-28 22:11:23 | 显示全部楼层
Andyhon 发表于 2012-9-25 14:43
是让您自行参考后修订

这样试吧!

vla-get-textstring 像这种vla开头的是什么函数,请教!,在常规的帮助文件中查不到.

点评

vla-* 开头的函数得查 VBA 的帮助  发表于 2012-9-29 15:22
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-5-23 13:09 , Processed in 0.189873 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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