Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LiSP to change text style font file definitions?

32 REPLIES 32
Reply
Message 1 of 33
Anonymous
10660 Views, 32 Replies

LiSP to change text style font file definitions?

We are changing our standard from romans.shx to Arial.ttf
My question is often times I get drawings with a half a dozen different text
style definitions.
Rather then clean up everything and look at everything I was wondering if
there was an efficient way
to read all the text style definitions. If the font file is romans.shx or
simplex.shx or txt.shx to change the
definition to use Arial.ttf
32 REPLIES 32
Message 2 of 33
Anonymous
in reply to: Anonymous

Just step through the style collection (is text style collection) and change
the 'FontFile' property as necessary.

--

Tim
"A blind man lets nothing block his vision."


"Dave Allen" wrote in message
news:5771705@discussion.autodesk.com...
We are changing our standard from romans.shx to Arial.ttf
My question is often times I get drawings with a half a dozen different text
style definitions.
Rather then clean up everything and look at everything I was wondering if
there was an efficient way
to read all the text style definitions. If the font file is romans.shx or
simplex.shx or txt.shx to change the
definition to use Arial.ttf
Message 3 of 33
Anonymous
in reply to: Anonymous

sorry that is beyond my hack-code capabilities


"T.Willey" wrote in message news:5771749@discussion.autodesk.com...
Just step through the style collection (is text style collection) and change
the 'FontFile' property as necessary.

--

Tim
"A blind man lets nothing block his vision."


"Dave Allen" wrote in message
news:5771705@discussion.autodesk.com...
We are changing our standard from romans.shx to Arial.ttf
My question is often times I get drawings with a half a dozen different text
style definitions.
Rather then clean up everything and look at everything I was wondering if
there was an efficient way
to read all the text style definitions. If the font file is romans.shx or
simplex.shx or txt.shx to change the
definition to use Arial.ttf
Message 4 of 33
Anonymous
in reply to: Anonymous

Try this

(vl-load-com)

(defun c:updateTextstyles (/ new)
(setq new (strcat (getenv "systemroot") "\\Fonts\\Arial.ttf"))
(vlax-map-collection
(vla-get-textstyles
(vla-get-activedocument
(vlax-get-acad-object)))
'(lambda (x / font)
(setq font (strcase (vla-get-fontfile x)))
(if (wcmatch font "ROMANS.SHX,SIMPLEX.SHX,TXT.SHX")
(vla-put-fontfile x new)))
)
(princ)
)

--
Autodesk Discussion Group Facilitator


"Dave Allen" wrote in message
news:5771775@discussion.autodesk.com...
sorry that is beyond my hack-code capabilities
Message 5 of 33
piyush.parihar24
in reply to: Anonymous

This LISP is not working in my case...

Command do run but furthur steps are not asked after performing the action..

Please Provide solution

Message 6 of 33

Hi

 

It's work for me. Use REGEN

 

@+

Message 7 of 33

Hi

 

AutoCAD has taken the command but further it's not executing the same...even after REGEN

Message 8 of 33

Another solution
Replace all texts in simplex, romans, etc... in arial

 

(defun c:arial(/ chg doc ele obj)
  (defun chg(obj)
    (and (vlax-property-available-p obj 'stylename)
	 (vl-position (strcase (vla-get-stylename obj)) '("ROMANS" "SIMPLEX" "TXT"))
      (vla-put-stylename obj "Arial")
    )
  )

  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (vla-startundomark doc)
  (vlax-for ele (vla-get-blocks doc)
    (vlax-for obj ele
      (if (eq (vla-get-objectname obj) "AcDbBlockReference")
	(mapcar 'chg (vlax-invoke obj 'getattributes))
	(chg obj)
      )
    )
  )
  (vla-endundomark doc)
  (princ)
)

 

@+

Message 9 of 33

Hi 

 

same error coming ...to be specific i want to convert all text styles in drawing to romans.shx

Message 10 of 33
m_badran
in reply to: Anonymous

Hi,try this.

(defun c:demo	(/ DOC FNTPTH STY )
  (vl-load-com)
  (setq	doc (vla-get-activedocument
	      (vlax-get-acad-object)
	    )
  )
  (setq FntPth (findfile "C:\\Windows\\Fonts\\arial.ttf"))
  (setq sty (vla-get-textstyles doc))
  (vlax-for s sty
    (vla-put-fontfile s FntPth)
  )
  (if (ssget "x" '((0 . "text")))
    (vlax-for n	(vla-get-activeselectionset doc)
    )
  )
  (vla-regen doc acAllViewports)
  (princ)
)

 

Message 11 of 33
piyush.parihar24
in reply to: m_badran

cool !!!..it's working....but i want to convert all text styles to "ROMANS.shx"...i made small changes in your lsp but doesn't work.Could you do that ?...I'm waiting
Message 12 of 33
piyush.parihar24
in reply to: m_badran

Hi,

cool !!!..it's working....but i want to convert all text styles to "ROMANS.shx"...I made small changes in your lsp but doesn't work.Could you do that ?...I'm waiting...

Message 13 of 33
m_badran
in reply to: piyush.parihar24

Ok,try this.

(defun c:demo	(/ DOC FNTPTH STY )
  (vl-load-com)
  (setq	doc (vla-get-activedocument
	      (vlax-get-acad-object)
	    )
  )
  (setq FntPth (findfile "ROMANS.shx"))
  (setq sty (vla-get-textstyles doc))
  (vlax-for s sty
    (vla-put-fontfile s FntPth)
  )
  (if (ssget "x" '((0 . "text")))
    (vlax-for n	(vla-get-activeselectionset doc)
    )
  )
  (vla-regen doc acAllViewports)
  (princ)
)
Message 14 of 33
piyush.parihar24
in reply to: m_badran

Great work mostafabadran it is working. Thank you So much for your help.
Message 15 of 33
m_badran
in reply to: piyush.parihar24

Your welcome.

Message 16 of 33
kpblc2000
in reply to: m_badran

Another one version (uses "romans.shx" firstly from AutoCAD support paths and then from Windows\Fonts directory. Changes ttf to shx and removes BigFont data:
[code](vl-load-com)

(defun c:ch-txtst (/ _kpblc-conv-string-to-list adoc file path)
(defun _kpblc-conv-string-to-list (string separator / i)
(cond ((= string "") nil)
((= separator "") (list string))
((vl-string-search separator string)
((lambda (/ pos res)
(while (setq pos (vl-string-search separator string))
(setq res (cons (substr string 1 pos) res)
string (substr string (+ (strlen separator) 1 pos))
) ;_ end of setq
) ;_ end of while
(reverse (cons string res))
) ;_ end of lambda
)
)
((wcmatch (strcase string) (strcat "*" (strcase separator) "*"))
((lambda (/ pos res _str prev)
(setq pos 1
prev 1
_str (substr string pos)
) ;_ end of setq
(while (<= pos (1+ (- (strlen string) (strlen separator))))
(if (wcmatch (strcase (substr string pos (strlen separator))) (strcase separator))
(setq res (cons (substr string 1 (1- pos)) res)
string (substr string (+ (strlen separator) pos))
pos 0
) ;_ end of setq
) ;_ end of if
(setq pos (1+ pos))
) ;_ end of while
(if (< (strlen string) (strlen separator))
(setq res (cons string res))
) ;_ end of if
(if (or (not res) (= _str string))
(setq res (list string))
(reverse res)
) ;_ end of if
) ;_ end of lambda
)
)
(t (list string))
) ;_ end of cond
) ;_ end of defun
(if (setq file "romans.shx"
file (if (and (setq path (car (vl-remove-if-not (function (lambda (x) (vl-directory-files x file)))
(vl-remove "" (_kpblc-conv-string-to-list (getenv "ACAD") ";"))
) ;_ end of vl-remove-if-not
) ;_ end of car
) ;_ end of setq
(setq path (findfile (strcat (vl-string-right-trim "\\" path) "\\" file)))
) ;_ end of and
path
(findfile file)
) ;_ end of if
) ;_ end of setq
(progn (vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
(vlax-for item (vla-get-textstyles adoc)
(setq item (entget (vlax-vla-object->ename item)))
(entmod (subst (cons 3 (strcat (vl-filename-base file) (vl-filename-extension file)))
(assoc 3 item)
(subst (cons 4 "") (assoc 4 item) item)
) ;_ end of subst
) ;_ end of entmod
(entupd (cdr (assoc -1 item)))
) ;_ end of vlax-for
(vla-regen adoc acallviewports)
(vla-endundomark adoc)
) ;_ end of progn
) ;_ end of if
(princ)
) ;_ end of defun[/code]

Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям! | Do you find the posts helpful? "LIKE" these posts!
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.


Алексей Кулик aka kpblc | Aleksei Kulik aka kpblc Facebook | LinkedIn
autolisp.ru
Техническая поддержка программистов Autodesk в СНГ
Библиотека пользовательских lisp-функций | Custom Lisp-function library

Message 17 of 33

What makes it different from what previously given solution?

Message 18 of 33

I told - romas.shx could be placed at c:\windows\fonts, not at ACAD support folders. Secondary - style could be used BigFont. My code makes BigFont off. You can use your code or any other versions - noone can say to you what to do and how to do it 😉

Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям! | Do you find the posts helpful? "LIKE" these posts!
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.


Алексей Кулик aka kpblc | Aleksei Kulik aka kpblc Facebook | LinkedIn
autolisp.ru
Техническая поддержка программистов Autodesk в СНГ
Библиотека пользовательских lisp-функций | Custom Lisp-function library

Message 19 of 33

Ok Got It..
Thanks A ton...
Message 20 of 33

I am sorry to ask this question in his forum. Burt will be great help if anyone can solve it.
I know how to customize the toolbar but only for AutoCAD basic command which are inbuilt.
If i want to make LISP Developed command in toolbar how will i make?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost