Jump to content

Text content to its Z value


Joe.

Recommended Posts

Hello

I have drawing with hundred texts objects and I want all of their text content to erase what is in the text field and write its own Z value as new content.

I know it is possible to do with Field function (Field-Objects-select certain object-Position-Z coordinate), but it is too time consuming and I have to select certain object to get Z value.

 

Is its possible to do to such kind of LISP that all text fields will change to text own Z value?

 

Thank You in advance

Link to comment
Share on other sites

You only need to look at how a text field is made for a Z value of existing text and overwrite string, using VL-put-textstring  obj newstr. You can copy the manual field command line and edit it into a lisp. Use mtext as a test. 

 

(defun c:t2rl ( / ss obj str)
(setq ss (ssget (list (cons 0 "TEXT"))))

(repeat (setq x (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
(setq str   (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-Objectid obj)) ">%).InsertionPoint \\f  \"%lu6%pt4\">%"))
(vla-put-textstring obj str)
)

(command "regen")
(princ)
)

 

  • Thanks 1
Link to comment
Share on other sites

14 hours ago, BIGAL said:

You only need to look at how a text field is made for a Z value of existing text and overwrite string, using VL-put-textstring  obj newstr. You can copy the manual field command line and edit it into a lisp. Use mtext as a test. 

 



(defun c:t2rl ( / ss obj str)
(setq ss (ssget (list (cons 0 "TEXT"))))

(repeat (setq x (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq x (- x 1)))))
(setq str   (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-Objectid obj)) ">%).InsertionPoint \\f  \"%lu6%pt4\">%"))
(vla-put-textstring obj str)
)

(command "regen")
(princ)
)

 

 

Wow, superb. Thank You very much!!

There should be quick link to tip the helper :).

Edited by Joe.
Link to comment
Share on other sites

1 hour ago, Joe. said:

There should be quick link to tip the helper :).

 

There is. If you click the little heart in the lower right corner of Bigal's post, it will add a point to his reputation.

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