Jump to content

simple change Text Value


ktbjx

Recommended Posts

i dont understand hot to use entmod to change the value of text

heres what i got so far..

i just wanted to change the number value.

(defun C:ddip (/ ss d dstring)
(setq ss (ssget "_:S" '((0 . "TEXT"))))
(setq d (getint "\nEnter Dip :"))
(setq dstring (strcat (itoa d)"°"))      
(entmod (subst dstring))
(princ))

Link to comment
Share on other sites

A Vl version also if d is only being used here why make it a number ? I know error trap but you have to have some faith in end users.

 

(defun c:ddip ( / obj str )
 (setq obj (vlax-ename->vla-object (car (entsel "pick text object"))))
  (if  (or (=  "AcDbText" (vla-get-objectname obj)) (=  "AcDbMText" (vla-get-objectname obj)) )
     (progn
     (setq str (strcat (getstring "\nEnter dip") "%%c"))
     (vla-put-textstring obj  str)
   )
 )
)

Edited by BIGAL
Link to comment
Share on other sites

No worries Tharwat.

 

Added the mtext check for simple text edit.

Hi,

 

Actually there is no need to convert to vla-object to get the job done.

Anyway, if I planned to write it with vlisp then I will go with the following track.

 

(defun c:ddip (/ obj str)
 (and (setq obj (car (entsel "\nPick text object :")))
      (setq obj (vlax-ename->vla-object obj))
      (wcmatch (vla-get-objectname obj) "AcDb*Text")
      (/= "" (setq str (getstring "\nEnter dip :")))
      (vla-put-textstring obj (strcat str "%%c"))
 )
 (princ)
) (vl-load-com)

Link to comment
Share on other sites

...
(wcmatch (vla-get-objectname obj) "AcDb*Text")
...

 

Thats clever! :thumbsup:

 

 

..
(vla-put-textstring obj (strcat str "%%c"))
...

 

Just a minor correction - it doesn't look like OP wants the diameter symbol, but the degree slope one:

_$ (vl-list->string '(37 37 99))
"%%c" ; <- labels pipe diameter
_$ (chr 176)
"°" ; <- labels slope in degrees

Link to comment
Share on other sites

Thats clever! :thumbsup:

Thank you. :)

 

Just a minor correction - it doesn't look like OP wants the diameter symbol, but the degree slope one:

 

I agree with you, so the OP has two options now ( diameter / degrees [ %%C , %%D ] ). ;)

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...