CHANGE ALL TEST TO ARIAL

CHANGE ALL TEST TO ARIAL

Anonymous
適用対象外
3,015件の閲覧回数
17件の返信
メッセージ1/18

CHANGE ALL TEST TO ARIAL

Anonymous
適用対象外

i am looking for a lisp that will change all visible text to Arial to  include mtext, dtext attributes, dimension & tables.  does anybody know if this exists or is it possible to build something like this?

 

thanx

0 件のいいね
解決済み
3,016件の閲覧回数
17件の返信
返信 (17)
メッセージ2/18

john.uhden
Mentor
Mentor

Yes, it is possible.  The method would be to change all text style definitions to use the Arial.TTF (normal) or ArialBd.TTF (bold) font.  This can be done programmatically (sp?) with AutoLisp.

John F. Uhden

0 件のいいね
メッセージ3/18

Kent1Cooper
Consultant
Consultant

This has >come up before<, and similarly in other threads [do some Searching if that one doesn't meet your need].

 

If you might have Mtext  with any font overrides  inside it, such an approach will not "fix" those.  Newer versions of AutoCAD have a "Remove formatting" option for selected content in the Mtext editor, but you would need to go into each Mtext object to do it that way.  For a more automated approach, search for the STRIPMTEXT routine.

Kent Cooper, AIA
0 件のいいね
メッセージ4/18

dbhunia
Advisor
Advisor

check this out.......

 

(defun C:CSTF ( / doc ss blname Text_Style_Lst obj)
	(defun Uni (lst) (if lst (cons (car lst) (Uni (vl-remove (car lst) (cdr lst))))))
	(setq doc (vla-get-activedocument (vlax-get-acad-object)))
	(if (setq ss (ssget "_A"))
		(progn 
			(foreach Ent (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
				(if (= "AcDbBlockReference" (vla-get-objectname (vlax-ename->vla-object Ent)))
					(progn
						(setq blname (vla-get-Effectivename (vlax-ename->vla-object Ent)))
						(vlax-for obj (vla-item (vla-get-blocks doc) blname)
							(if (wcmatch (vla-get-objectname obj) "*Text,AcDbLeader")
								(setq Text_Style_Lst (cons (vla-get-stylename obj) Text_Style_Lst ))
							)
							(if (and (wcmatch (vla-get-objectname obj) "AcDbAttributeDefinition")
									 (eq :vlax-false (vla-get-Invisible obj))
								)
								(setq Text_Style_Lst (cons (vla-get-stylename obj) Text_Style_Lst ))
							)
							(if (wcmatch (vla-get-objectname obj) "*Dimension")
								(setq Text_Style_Lst (cons (vla-get-TextStyle obj) Text_Style_Lst ))
							)
							(if (wcmatch (vla-get-objectname obj) "AcDbMLeader")
								(setq Text_Style_Lst (cons (vla-get-textstylename obj) Text_Style_Lst ))
							)
						)
					)
					(progn
						(setq obj (vlax-ename->vla-object Ent))
						(if (wcmatch (vla-get-objectname obj) "*Text,AcDbLeader")
							(setq Text_Style_Lst (cons (vla-get-stylename obj) Text_Style_Lst ))
						)
						(if (wcmatch (vla-get-objectname obj) "*Dimension")
							(setq Text_Style_Lst (cons (vla-get-TextStyle obj) Text_Style_Lst ))
						)
						(if (wcmatch (vla-get-objectname obj) "AcDbMLeader")
							(setq Text_Style_Lst (cons (vla-get-textstylename obj) Text_Style_Lst ))
						)
					)
				)
			)
		)
	)
	(if Text_Style_Lst 
		(progn
			(setq Text_Style_Lst (uni Text_Style_Lst))
			(vlax-for obj (vla-get-textstyles doc)
				(if (member (vla-get-name obj) Text_Style_Lst)(vla-put-fontfile obj "arial.ttf"))
			)
			(vla-regen doc acallviewports)
		)
	)
	(princ)
)

Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 件のいいね
メッセージ5/18

john.uhden
Mentor
Mentor

That is very ambitious.

I just thought he wanted to change the text style definitions...

(defun c:Arial ( / Doc ent)
  (setq *acad* (vlax-get-acad-object))
  (setq Doc (vlax-get *acad* 'ActiveDocument))
  (vlax-for item (vlax-get Doc 'Textstyles)
    ;; (vlax-put item 'Fontfile "Arial.ttf")  ;; but this doesn't work
    (setq ent (entget (vlax-vla-object->ename item)))
    (entmod (subst '(3 . "Arial.ttf")(assoc 3 ent) ent)) ;; yet this does
  )
  (princ)
)

John F. Uhden

0 件のいいね
メッセージ6/18

dbhunia
Advisor
Advisor

@john.uhden  and @Kent1Cooper  my 1st thought was like both of you. which will change "Font" of  all "Text Style" of the Drawing.

 

But what if, some one wants to changes only those "Font" of the "Text Style" which have been used in the Drawing?

 

 

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 件のいいね
メッセージ7/18

ronjonp
Advisor
Advisor

@dbhunia wrote:

@john.uhden  and @Kent1Cooper  my 1st thought was like both of you. which will change "Font" of  all "Text Style" of the Drawing.

 

But what if, some one wants to changes only those "Font" of the "Text Style" which have been used in the Drawing?

 

 

 


You could also simplify this a bit if you have a textsyle already setup named "arial".

(defun c:foo nil
  (vlax-for a (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
    (vlax-for b	a
      (if (vlax-property-available-p b 'stylename)
	(vl-catch-all-apply 'vla-put-stylename (list b "Arial"))
      )
    )
  )
  (princ)
)

Like Kent mentioned though this will not fix hardcoded mtext and blocks with attributes will most likely have to be synced.

 

Or something like this to create the font 'ArialFixed'.

(defun c:foo (/ ad)
  (setq ad (vla-get-activedocument (vlax-get-acad-object)))
  (vla-put-fontfile a (vla-add (vla-get-textstyles ad) "ArialFixed") "arial.ttf")
  (vlax-for a (vla-get-blocks ad)
    (vlax-for b	a
      (if (vlax-property-available-p b 'stylename)
	(vl-catch-all-apply 'vla-put-stylename (list b "ArialFixed"))
      )
    )
  )
  (princ)
)
(vl-load-com)

 

0 件のいいね
メッセージ8/18

ronjonp
Advisor
Advisor

@dbhunia Using the same logic your code could be condensed to this 😉

(defun c:foo (/ ad n r)
  (vlax-for a (vla-get-blocks (setq ad (vla-get-activedocument (vlax-get-acad-object))))
    (vlax-for b	a
      (if (vlax-property-available-p b 'stylename)
	(or (vl-position (setq n (vla-get-stylename b)) r) (setq r (cons n r)))
      )
    )
  )
  (foreach x r (vla-put-fontfile (vla-item (vla-get-textstyles ad) x) "arial.ttf"))
  (princ)
)
(vl-load-com)
0 件のいいね
メッセージ9/18

john.uhden
Mentor
Mentor
And what if the text contains only 6 instances of the letter "e" and has a
total width of between 15 and 20 units, and is not orthogonal to the
current UCS?

I'm sorry. I just took the word "ALL" literally. The OP didn't include
the adjective"existing" so I figured that "ALL" applied to the future as
well.

John F. Uhden

0 件のいいね
メッセージ10/18

Kent1Cooper
Consultant
Consultant

@john.uhden wrote:
.... I just took the word "ALL" literally. The OP didn't include
the adjective"existing" ....

… but they did use the word "visible," so I can understand why someone would think that meant already in the drawing.

Kent Cooper, AIA
0 件のいいね
メッセージ11/18

john.uhden
Mentor
Mentor
But did he use the term "*only* visible?" Who cares about invisible ones
anyway?

John F. Uhden

0 件のいいね
メッセージ12/18

Anonymous
適用対象外

The invisible was in case i wanted to hide a layer or something.

Anyway thanks to all.  but on all these lisps i get the following error.  "; error: Automation Error. Filer error".  does anybody know why i get this?

 

thanx

0 件のいいね
メッセージ13/18

ronjonp
Advisor
Advisor
解決済み

@Anonymous wrote:

The invisible was in case i wanted to hide a layer or something.

Anyway thanks to all.  but on all these lisps i get the following error.  "; error: Automation Error. Filer error".  does anybody know why i get this?

 

thanx


What does this return?

(print (findfile (strcat (getenv "windir") "\\Fonts\\Arial.ttf")))

 If that returns something other than 'nil' then the code below might work for you.

(defun c:foo (/ ad ff n r)
  (cond	((setq ff (findfile (strcat (getenv "windir") "\\Fonts\\Arial.ttf")))
	 (vlax-for a (vla-get-blocks (setq ad (vla-get-activedocument (vlax-get-acad-object))))
	   (vlax-for b a
	     (if (vlax-property-available-p b 'stylename)
	       (or (vl-position (setq n (vla-get-stylename b)) r) (setq r (cons n r)))
	     )
	   )
	 )
	 (foreach x r (vla-put-fontfile (vla-item (vla-get-textstyles ad) x) ff))
	 (princ)
	)
	((alert "Arial font not found!"))
  )
)
(vl-load-com)
0 件のいいね
メッセージ14/18

Anonymous
適用対象外

I get "C:\\WINDOWS\\Fonts\\Arial.ttf" "C:\\WINDOWS\\Fonts\\Arial.ttf".  Just and FYI the point of turning everything into a true type font is so it can be searchable after printed to PDF.

 

thanx

0 件のいいね
メッセージ15/18

john.uhden
Mentor
Mentor
If all the lisps are expecting that AutoCAD will find ARIAL.TTF, then
there's something whacko in your AutoCAD. I think it's supposed to
automatically look for TTF files in the Windows/Fonts folder. Or for some
reason you don't have an ARIAL.TTF file (highly unlikely).

John F. Uhden

メッセージ16/18

Anonymous
適用対象外

when i accept the solution it would be nice to add a comment but i did not see where to do that.  Anyway this is working the way i want now.

 

thank you very much

0 件のいいね
メッセージ17/18

ronjonp
Advisor
Advisor

@Anonymous wrote:

when i accept the solution it would be nice to add a comment but i did not see where to do that.  Anyway this is working the way i want now.

 

thank you very much


Glad to help out (y).

0 件のいいね
メッセージ18/18

LDShaw
Collaborator
Collaborator

Just pointing to a thread that had much the same question. 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-for-text-style-arial-width-1-00...

 ronjonp. answer worked well there. 

0 件のいいね