乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 87|回复: 1

[编程交流] Test an object to see if it�

[复制链接]

6

主题

44

帖子

39

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-6 17:20:27 | 显示全部楼层 |阅读模式
I have a routine that I use frequently at work and would like to improve it. The problem I have with it currently is that if I mis-click it cycles to the next number and I have to exit the command and start again. Basically I'd like the command to test the object to make sure it's text before running the iteration and "change" command.
 
  1. (defun c:cx() ;;Edits text objects by replacing current text with a prefix and an incremental numerical suffix  (setq prefix (getstring "Prefix:")) ;; prompts the user for the string prefix (setq startint (getint "Initial number:")) ;; prompts the user for the initial number (setq cnt 0) ;; intializes the counter  (while   (PROGN     (setq ent (entsel)) ;;requests the first text to edit     (setq newstring (strcat prefix (itoa (+ startint cnt)))) ;;created the string     (command "change" (car ent) "" "" "" "" "" "" newstring) ;;replace the string     (setq cnt (1+ cnt)) ;; increment the counter    )  ) )
 
Thoughts?
回复

使用道具 举报

0

主题

132

帖子

198

银币

限制会员

铜币
-21
发表于 2022-7-6 18:20:50 | 显示全部楼层
Probably would want to replace entsel with something like this
 
(ssget '((0 . "TEXT")))
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-4 16:28 , Processed in 0.316496 second(s), 56 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表