乐筑天下

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

[编程交流] vl-string-translate

[复制链接]

21

主题

155

帖子

135

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
105
发表于 2022-7-5 18:25:04 | 显示全部楼层 |阅读模式
I'm trying to use the
  1. vl-string-translate
function to replace a character within a text string thus:
  1. (defun c:test ( / a b )(setq a (entget(car(entsel))))        (setq b(cdr(assoc 1 a)))                 (princ (vl-string-translate "NO." "No." b)) )
But after many experiments in the Console all I keep getting is BoILER No. 2 instead of BOILER No. 2.
 
Anyone know how to make  
  1. vl-string-translate
only find an "o" when preceded by a "N" ?
回复

使用道具 举报

1

主题

475

帖子

481

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 18:46:28 | 显示全部楼层
Try vl-string-subst
  1. (defun c:test ( / a b )(setq a (entget(car(entsel))))        (setq b(cdr(assoc 1 a)))                 (princ (vl-string-subst "No." "NO." b)) )
 
Henrique
回复

使用道具 举报

21

主题

155

帖子

135

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
105
发表于 2022-7-5 19:00:19 | 显示全部楼层
Henrique, thank you very much. I've not seen that one before.
 
All I've got to do is put in an entmod now
  1. (defun c:test ( / a b ntext)(setq a (entget(car(entsel))))        (setq b(cdr(assoc 1 a)))                 (setq ntext (vl-string-subst "No." "NO." b))                 (entmod(subst (cons 1 ntext) (assoc 1 a) a)) )(vl-load-com)
回复

使用道具 举报

1

主题

475

帖子

481

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-5 19:09:46 | 显示全部楼层
You're welcome!
 
Glad I could help
Henrique
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 19:13:47 | 显示全部楼层
If your using Vl why not all, saves remembering dxf codes
  1. (defun c:test ( / a b ntext)(setq obj (vlax-ename->vla-object (car(entsel))))(setq b (vla-get-textstring obj))(setq ntext (vl-string-subst "No." "NO." b))(vla-put-textstring obj ntext))(vl-load-com)
回复

使用道具 举报

21

主题

155

帖子

135

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
105
发表于 2022-7-5 19:37:00 | 显示全部楼层
 
Good plan BIGAL. Thank you v much, I shall give it a try when I get into work soon.
 
I've only just (this month) entered the realm of VL type functions, & this is my first attempt. As you can see from the poorly chosen VL from the subject, I'm somewhat inexperienced, although I've copied other folks VL code before.
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-12 19:57 , Processed in 1.398044 second(s), 64 queries .

© 2020-2025 乐筑天下

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