Jump to content

vl-string-translate


Happy Hobbit

Recommended Posts

I'm trying to use the

vl-string-translate

function to replace a character within a text string thus:

(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

vl-string-translate

only find an "o" when preceded by a "N" ?

Link to comment
Share on other sites

Henrique, thank you very much. I've not seen that one before.

 

All I've got to do is put in an entmod now

 (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)

Edited by Happy Hobbit
Link to comment
Share on other sites

If your using Vl why not all, saves remembering dxf codes

(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)

Link to comment
Share on other sites

If your using Vl why not all, saves remembering dxf codes

 

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...