Changing all text style including all blocks

Changing all text style including all blocks

joe_kohli
Advocate Advocate
2,578 Views
10 Replies
Message 1 of 11

Changing all text style including all blocks

joe_kohli
Advocate
Advocate

Is there a way or a script that can be wrote to convert ALL text (attributed, embedded in blocks, etc.) to a different style? Instead of using BATMAN

0 Likes
Accepted solutions (1)
2,579 Views
10 Replies
Replies (10)
Message 2 of 11

cadffm
Consultant
Consultant

Command STANDARDS

Use a file WITHOUT the styles you woun't but with the style you want to merge to.

Sebastian

0 Likes
Message 3 of 11

pendean
Community Legend
Community Legend
HELP in the program is a good place to start (yes, you'll need to have 'correct' content already at hand like template files etc.)
https://help.autodesk.com/view/ACD/2025/ENU/?guid=GUID-F8B47FBB-1276-4D74-BA89-0440CB4E4866#:~:text=...
OR
find and use LISP that over the years do at you want or get close to it, like this
https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-all-text-to-standard-text-style/...
0 Likes
Message 4 of 11

Kent1Cooper
Consultant
Consultant
Accepted solution

Would it suffice to change all Style definitions to use the same font [and perhaps also other characteristics like obliquing angle and width factor, possibly even height], rather than change all text-variety objects to the same Style?  You would still have multiple Styles defined, but they would all look the same.  For example, we have this available:

(defun C:ASA9 (/ cmde sty); = All Styles Arial font at 0.9 width factor
  (setq cmde (getvar 'cmdecho))
  (setvar 'cmdecho 0)
  (while (setq sty (cdr (assoc 2 (tblnext "style" (not sty)))))
    (if (not (wcmatch sty "*|*")); not in an Xref
      (command "_.style" sty "Arial" "" 0.9 "" "" "")
    ); if
  ); while
  (setvar 'cmdecho cmde)
  (princ)
); defun
(prompt "\nType ASA9 to set All Styles to Arial font at 0.9 width factor.")

 

Kent Cooper, AIA
Message 5 of 11

joe_kohli
Advocate
Advocate

Kent, this may actually work. I tried it and it converted every piece of text to Arial in my drawing. To give you a small idea of what I am trying to do: I have hundreds of drawings that were unfortunately drawn under the Romans.shx font and have Romans style. None of these drawings have readable text when using Adobe/Bluebeam. I am in the process of converting them over to readable text. So I'm not so much worried about the style per say as I am about getting the whole drawing into readable text format. This way, the users then can search a database and their search results would pull up whatever drawing had that particular search word in it. To keep it all coherent, I would love to have both style and font changed but I understand if you can't do that. I'm looking for a "STANDARD" style with 0.75 width factor and RomanS_IV25 font.

0 Likes
Message 6 of 11

Kent1Cooper
Consultant
Consultant

[I assume you are aware that changing the font will affect things like word wrapping in Mtext, whether Dimension text fits between extension lines, etc.  So it should be followed by a careful look-over to check for things that may need adjustment.]

 

One potential complication with changing all Text and Text-like objects to the same Style, rather than just all Styles to the same font:  Do you ever use Styles with fixed height?  If you use different heights at all, of course any "universal" Style would need to be defined at "zero" height to accommodate that variety.  So anything in Styles that had a fixed height will lose that characteristic, if that matters to you.

Kent Cooper, AIA
Message 7 of 11

joe_kohli
Advocate
Advocate

Ya I was looking at some of those issues and I believe I will be fortunate enough to have bypassed those. The script you provided does everything I need it to do (of course with a few tweeks to the code to my liking). Thank Kent! I appreciate your support yet again.

0 Likes
Message 8 of 11

joe_kohli
Advocate
Advocate

Kent, you were right. Some of the drawings are being modified through the script but it is negatively affecting certain characters within my drawings. Can the script be changed so that it would perform this execution: Change all font to RomanS_IV25 with a width factor of 0.75, HOWEVER, if the drawing contains this criteria,

 

Text Style: LType

Font Name: Arial Narrow

Font Style: Bold

Width Factor: 1.00

 

DO NOT convert it. Simply ignore this text and keep it at Arial Narrow.

 

 

Here is the lsp I am currently running:

 

(defun C:r25 (/ cmde sty); = All Styles RomanS_IV25 font at 0.75 width factor
(setq cmde (getvar 'cmdecho))
(setvar 'cmdecho 0)
(while (setq sty (cdr (assoc 2 (tblnext "style" (not sty)))))
(if (not (wcmatch sty "*|*")); not in an Xref
(command "_.style" sty "RomanS_IV25" "" 0.75 "" "" "")
); if
); while
(setvar 'cmdecho cmde)
(princ)
); defun
(prompt "\nType ASA9 to set All Styles to RomanS_IV25 font at 0.75 width factor.")

0 Likes
Message 9 of 11

insub_beckley
Community Visitor
Community Visitor

I have the following lisp which is modified from something Kent Cooper posted somewhere. It will change the text style of all text or mtext even if they are in a block or attribute definition. It does work well for this. The only thing I modified was to add a prompt to define what the replacement style would be. I was trying to use this to purge all disparate styles within the drawing.

 

The only thing I cannot figure how to do is to also replace all the text styles within dimension styles. I've went round and round with Copilot and always there is an error when trying to reference the TextStyle property of a dimstyle. Here's the working lisp for changing all text styles:

(defun C:CTS ()
  ;; = Text (& Mtext) [to] specified Style, including in Blocks,
  ;; and Attributes, both in Blocks & unassociated Att. Def's
  ;; Created by KENT COOPER, AIA and edited by InSub Beckley.
  ;; v2.0 makes the newStyle user definable instead of hardcoded.
  
  (vl-load-com) ; Ensure Visual LISP functions are loaded
  (setq newStyle (getstring "\nEnter the new text style name: "))
  (setq tss (ssget "_X" '((0 . "*TEXT,ATTDEF"))))
  (if tss
    (repeat (setq n (sslength tss))
      (setq edata (entget (ssname tss (setq n (1- n)))))
      (entmod (subst (cons 7 newStyle) (assoc 7 edata) edata))
    ); repeat
  ); if
  (setq blkname nil blklist nil)
  (while (setq blkname (cdadr (tblnext "block" (not blkname))))
    (if
      (not
        (or
          (wcmatch blkname "`*D*,*|*") ; Dimension or Xref-dependent
          (assoc 1 (tblsearch "block" blkname)) ; an Xref
          (member blkname blklist) ; already in the list
        ); or
      ); not
      (setq blklist (cons blkname blklist))
    ); if
  ); while
  (foreach blkname blklist
    (setq ent (tblobjname "block" blkname))
    (while (setq ent (entnext ent))
      (if (wcmatch (cdr (assoc 0 (setq edata (entget ent)))) "*TEXT,ATTDEF")
        (entmod (subst (cons 7 newStyle) (assoc 7 edata) edata))
      ); if
    ); while
  ); foreach
  (command
    "_.regen"
    "_.attsync" "_name" "*"
  ); command
  (princ)
); defun
0 Likes
Message 10 of 11

Kent1Cooper
Consultant
Consultant

@insub_beckley wrote:

.... to also replace all the text styles within dimension styles. ....


That's different because the Text Style assigned to a Dimension Style is not in the top-level entity data directly, but is a sub-entry under the 340-code entry.  Rather than dig down to modify sub-level entries in entity data, it's probably easier to do it this way [untested]:

  (while (setq dimstname (cdadr (tblnext "dimstyle" (not dimstname))))
    (if (not (wcmatch blkname "*|*") ; not Xref-dependent
      (progn ; then
        (command "_.dimstyle" "_restore" dimstname); all its options current
        (setvar 'dimtxsty newStyle); make it current
        (command "_.dimstyle" "_save" dimstname "_yes"); replace it in DimStyle
      (; progn
    ); if
  ); while

Try adding that between lines 36 & 37 of your posted code.

Kent Cooper, AIA
Message 11 of 11

Kent1Cooper
Consultant
Consultant

@joe_kohli wrote:

... if the drawing contains this criteria,

Text Style: LType

....

DO NOT convert it. Simply ignore this text and keep it at Arial Narrow.

....


Sorry I didn't catch this at the time....

 

Would it suffice to simply bypass the Style named LType if it exists, but allow it to keep its current font and width factor even if it may not be Arial Narrow Bold at a width factor of 1?  [That would save a lot of work checking those other properties, though that could be done if necessary.]

 

If so, it should be enough to simply replace this line:

(if (not (wcmatch sty "*|*")); not in an Xref

with this:

(if (not (wcmatch sty "*|*,LType")); not in an Xref nor named "LType"

Kent Cooper, AIA
0 Likes