Jump to content

Explode Word In Autocad to individual text characters


suryacad

Recommended Posts

But the lisp returns error in Autocad 2012 - Start command with XTEXT.; error: malformed list on input

I needed it to do some number and word sorting in a messed up drawing.

 

That means the routine is in need of a close bracket and in that program it needs to be at the end of the program .

Link to comment
Share on other sites

That means the routine is in need of a close bracket and in that program it needs to be at the end of the program

 

Thanks Tharwat.

 

; TIP #637 XTEXT.LSP By Ashoke Bhattacharya CADalyst Magazine March 1991
; ------------------------------------------------------------------------
; DESCRIPTION:  Explodes a line of text into its component letters. 
; ------------------------------------------------------------------------
(princ "\nStart command with XTEXT.")(graphscr)(princ)
; ------------------------------------------------------------------------
(defun C:XTEXT ()
 (setvar "CMDECHO" 0)
 (setq A1 (entget (car (entsel
   "\nSelect text: "))))
 (setq A2 (cdr (assoc -1 A1)))
 (command "ERASE" A2 "")
 (setq A (cdr (assoc 1 A1)))
 (setq SP (cdr (assoc 10 A1)))
 (setq HT (cdr (assoc 40 A1)))
 (setq B (strlen A))
 (setq B1 1)
 (repeat B
   (setq C (substr A B1 1))
   (command "TEXT" SP HT 0 C)
   (setq B1 (+ B1 1))
   (setq HT1 HT)
   (if (= 108 (ascii C))
     (setq HT1 (/ HT 2)))
   (if (= 105 (ascii C))
     (setq HT1 (/ HT 3)))
   (if (= 73 (ascii C))
     (setq HT1 (/ HT 1.5)))
   (setq SP (polar SP 0 HT1))
 )
(redraw)
(princ)
)

 

now the error stopped but it explodes any WORD into OOOO O's and the position of text is also changed. any work around so that it just explodes the word into its individual character and remains in the same place.

Thanks

Link to comment
Share on other sites

....now the error stopped but it explodes any WORD into OOOO O's and .....

 

How's that again? O's ? Let us have a look at that drawing file of yours so we can see why its doing that.

Link to comment
Share on other sites

I posted a explode text down to elements T2G but the OP just wants individual characters.

remains in the same place
The problem with text is that it is kerned look at AW the top of the W is really close to the bottom of the A. If you use the text style Mono.shx it has fixed spacing each character is same width, To explode WORDAL is probably not bad some combo's will increase in width. You could write your own kerning and adjust the spacing of next character.
Link to comment
Share on other sites

Sorry for the late reply.

Actually i tried the lisp on another file works totally fine. but the text is still moved from original position - using Autocad 2013

Attached drawing for churning out unlimited supply of Cherrios :D

new block.dwg

Link to comment
Share on other sites

You got what you basically asked for. No one can account for the many subtleties of every font out there in a lisp routine. Bottom line...change your font until you find one where the individual characters are not shifted or where the shift is ever so slight.

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