Jump to content

EXTRACT ONLY THE "TEXTSIZE"/"TEXTHEIGHT" VALUE FROM A STRING OF TEXT


Recommended Posts

Posted

EXAMPLE 01 - 5mm HIGH TEXT

"100mm THICK MILD STEEL FLAT BAR"

###########################

above is a string of text on a drawing ------ question is as follows____how can I extract or obtain (with a lisp function) only the "textsize"/"textheight" value from the string to

use the value in a lisp routine

 

appreciated

NIEKO

 

Posted

Open a notepad document, copy/paste this code, save as print_text_height.lsp (feel free to rename, but keep the .lsp, and make sure ther's no .txt at the end of that).

Drag the .lsp file in your Autocad active document

Type command GTH, press enter

 


(defun c:gth ( / th)
  (setq th (cdr (assoc 40 (entget (car (entsel "\nSelect TEXT object: "))))))
  (princ "\nText height: ")
  (princ th)
  (princ)
)

Posted

Emmanuel

Thanks a lot. I really appretiate it

 

NIEKO

  • Like 1
Posted

Another same thing using v lisp

 


(setq obj (vlax-ename->vla-object (car (entsel "pick text object"))))
(setq ht (vla-get-height obj))

(alert (strcat "height is  " (rtos ht 2 1)))

Posted

BIGAL

Thanks a lot for your help and input

I appreciate it very much

 

I would like to compliment all you guys for an excellent CAD forum

 

 

NIEKO

Posted

If you want the actual height of the text in the drawing use the TEXTBOX function. A string with the same height like "1234" will not be the same physical height as "{1234,".

 

Try it :)

(if (setq e (car (entsel "\nPick text: ")))
  (print (abs (apply '- (mapcar 'cadr (textbox (entget e))))))
)

 

  • Like 2
Posted

Good one ronjonp,  don't forget droppers, superscript, subscript.

 

Jj Ggx²

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