Jump to content

Wrong text font


ElAmigo

Recommended Posts

Hello friends,

I have the following code which sets all textstyles of all text and mtext in the model to Company:

(defun c:ChangeAllTextStyles (/ ss obj entData)
  (setq ss (ssget "X" '((0 . "TEXT,MTEXT"))))                                       ;; Select all TEXT and MTEXT objects in the drawing
  (if ss                                                                            ;; If text objects are found
    (progn
      (repeat (sslength ss)                                                        ;; Iterate through each object in the selection set
        (setq obj (ssname ss 0))                                                   ;; Get the object
        (setq entData (entget obj))                                                ;; Get the entity data
        (setq entData (subst (cons 7 "Company") (assoc 7 entData) entData))         ;; Change the text style to "Company"
        (entmod entData)                                                           ;; Apply the modification
        (ssdel obj ss)                                                             ;; Remove the object from the selection set
      )
      (princ "\nAll text styles have been updated to 'Company'.")
    )
    (princ "\nNo text objects found.")
  )
  (princ)                                                                          ;; Clean up the screen upon completion
)

 

However, some text doesnt get the right font. When I click on it the text contents start with: \fArial|b0|i0; and then the actual text content.

It gets removed when I change the text style manually but I couldn't get it fixed in my lisp. I hope someone can help.

 

Edited by ElAmigo
Link to comment
Share on other sites

That is usually because the font was changed in the text editor rather than properties - you can use something like strip m text or look at Lee Mac to remove text formatting

Link to comment
Share on other sites

58 minutes ago, Steven P said:

That is usually because the font was changed in the text editor rather than properties - you can use something like strip m text or look at Lee Mac to remove text formatting

Thank you! I did a quick google search and found this: https://cadabyss.wordpress.com/2010/01/04/stripmtext-v5-0/. The download on this site doesn't work. And then I found the reply by Devitg on this forum:

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/stripmtext-v5-0-lisp-routine/td-p/2673838

Then I could apply the code with:

(defun c:striptest ( / ss)
  (setq ss (ssget "X" '((0 . "MTEXT"))))                                       ;; Select all TEXT and MTEXT objects in the drawing
  (if ss 
    (STRIPMTEXT ss "F") 
  )
)

 

  • Like 1
Link to comment
Share on other sites

Perfect!

 

Stripmtext is a handy little tool

Edited by Steven P
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...