LISP For Text Style - Arial Width 1.00 for Entire Drawing

LISP For Text Style - Arial Width 1.00 for Entire Drawing

designGTNEK
Contributor Contributor
726 Views
4 Replies
Message 1 of 5

LISP For Text Style - Arial Width 1.00 for Entire Drawing

designGTNEK
Contributor
Contributor

Hi All,

 

I know similar has been requested but I have not found one that works properly.I need a LISP routine for a task that would allow all fonts within a drawing to be converted to Arial Font and a width factor of 1, for every Text Style in a drawing.

 

I have been doing this Manually by:

1. Opening a Design (an external reference .dwg from external Architects/Structural engineers)

2. Type "STYLE" hit enter

3 In Text Style Box going through each text style and choosing Arial Font Name and manually typing 1 for width factor, then hit Apply.

4. Repeat step 3 for all styles..

 

I don't want the text height or any other things to change.

 

It is very tedious. The reason?! I have discovered in my designs that all of the External Referenced designs I use within my own design have terrible text style and font choices and it is the main cause of slow and jerky performance within my own design. Once switched to Arial and 1.00 width, the Xrefs no longer cause any issues!

 

Thanks in advance!

 

designGTNEK_0-1694555894465.png

 

0 Likes
Accepted solutions (1)
727 Views
4 Replies
Replies (4)
Message 2 of 5

paullimapa
Mentor
Mentor

The lisp code from this link should get you at least to getting all styles to be arial. Changing the width factor should be fairly simple to modify as well

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/change-all-test-to-arial/m-p/9027786...


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 5

LDShaw
Collaborator
Collaborator
Accepted solution

I did this one a while back to bring acad into revit. 

(if (findfile (setq f (strcat (getenv "windir") "\\Fonts\\Arial.ttf")))
    (progn
      (vlax-for s (vla-get-textstyles (setq doc (vla-get-activedocument (vlax-get-acad-object))))
        (vla-put-fontfile s f)
        (vla-put-width s 1.0)
        ;; RJP » 2020-04-29
        (vla-setfont s "Arial" :vlax-false :vlax-false 0 34)
      )
      (vla-regen doc acallviewports)
    )
  )

Here is the full version. Take what you need.

(defun c:Rsetup (/ f doc clayr layer ss store_temp dmscl sty1)

;set fonts all fonts to arial.
 
 (if (findfile (setq f (strcat (getenv "windir") "\\Fonts\\Arial.ttf")))
    (progn
      (vlax-for s (vla-get-textstyles (setq doc (vla-get-activedocument (vlax-get-acad-object))))
        (vla-put-fontfile s f)
        (vla-put-width s 1.0)
        ;; RJP » 2020-04-29
        (vla-setfont s "Arial" :vlax-false :vlax-false 0 34)
      )
      (vla-regen doc acallviewports)
    )
  )

;updates layersand layer standards to good revit colors. 

		(setq 
			clayr (getvar "clayer")
			
			lt1 "G-LITE"
			mid1 "G-SCHED,G-MEDIUM,0"
			txt1 "*text*,*KEYN*"
			hvy1 "G-HEAVY"
			
			lt2 "8"
			mid2 "5"
			txt2 "6"
			hvy2 "4"
        )
		
(command "-layer" "c" lt2 lt1 "")
(command "-layer" "c" mid2 mid1 "")
(command "-layer" "c" txt2 txt1 "")
(command "-layer" "c" hvy2 hvy1 "")
 
		(setvar "clayer" clayr)

 (alert "General layers are now set to Revit specs.")
  
;setup scale

;Binging in fontstyle if needed. 


	(command "-INSERT" "../../DEFAULT/mech/dc notes/Text-Dim-Styles" "0,0" "1" "" "0")
	(command "erase" "l" "")
	

;Asking for scale.
; (setq ss (ssget "_P")) will collect exploded block into selection set. 


(setq store_temp dmscl)
	(prompt  "\nWhat is your scale? <")(if (/= nil) (progn(prin1 dmscl)))(prompt  ">:")
	(setq dmscl (getreal))

		(setq
		sty1 "dc"
		)

(setvar "dimscale" dmscl)
(setvar "ltscale" dmscl)


(if (= dmscl 1)
    (progn ; then
	(setq
	sty1 "dc"
	
	)
		(setvar "textstyle" sty1)
		(command "-dimstyle" "r" sty1)
	) ;progn
)

(if (= dmscl 12)
    (progn ; then
	(setq
	sty1 "dc-012"
	)
		(setvar "textstyle" sty1)
		(command "-dimstyle" "r" sty1)
	) ;progn
)

(if (= dmscl 24)
    (progn ; then
	(setq
	sty1 "dc-024"
	)
		(setvar "textstyle" sty1)
		(command "-dimstyle" "r" sty1)
	) ;progn
)

(if (= dmscl 32)
    (progn ; then
	(setq
	sty1 "dc-032"
	)
		(setvar "textstyle" sty1)
		(command "-dimstyle" "r" sty1)
	) ;progn
)

(if (= dmscl 48)
    (progn ; then
	(setq
	sty1 "dc-048"
	)
		(setvar "textstyle" sty1)
		(command "-dimstyle" "r" sty1)
	) ;progn
)


(if (= dmscl 64)
    (progn ; then
	(setq
	sty1 "dc-064"
	)
		(setvar "textstyle" sty1)
		(command "-dimstyle" "r" sty1)
	) ;progn
)

(if (= dmscl 96)
    (progn ; then
	(setq
	sty1 "dc-096"
	)
		(setvar "textstyle" sty1)
		(command "-dimstyle" "r" sty1)
	) ;progn
)

(if (= dmscl 128)
    (progn ; then
	(setq
	sty1 "dc-128"
	)
		(setvar "textstyle" sty1)
		(command "-dimstyle" "r" sty1)
	) ;progn
)

(if (= dmscl 192)
    (progn ; then
	(setq
	sty1 "dc-192"
	)
		(setvar "textstyle" sty1)
		(command "-dimstyle" "r" sty1)
	) ;progn
)
  
)



Message 4 of 5

designGTNEK
Contributor
Contributor

Woo hoo! This worked perfectly, Thank you so much!

 

For future reference, if you ever see any posts about people struggling with External References slowing down their designs, this is the solution to that problem, it is the different fonts and text widths within the Xrefs that cause lots of problems,

 

(if (findfile (setq f (strcat (getenv "windir") "\\Fonts\\Arial.ttf")))
    (progn
      (vlax-for s (vla-get-textstyles (setq doc (vla-get-activedocument (vlax-get-acad-object))))
        (vla-put-fontfile s f)
        (vla-put-width s 1.0)
        ;; RJP » 2020-04-29
        (vla-setfont s "Arial" :vlax-false :vlax-false 0 34)
      )
      (vla-regen doc acallviewports)
    )
  )

 

0 Likes
Message 5 of 5

LDShaw
Collaborator
Collaborator

Nice to be able to help every now and again. BUT
Credit where it's due.

;; RJP » 2020-04-29


and this time it goes out to Ron for helping me out
Thanks
 ronjonp.