need custom LISP that searches for specific font within a style and replaces it

need custom LISP that searches for specific font within a style and replaces it

Anonymous
Not applicable
932 Views
4 Replies
Message 1 of 5

need custom LISP that searches for specific font within a style and replaces it

Anonymous
Not applicable

LIke the topic says. I am 95% there, but i do not know all the getvar lisp coding

I want this lisp to be able to run on our consultants' files that are dumping out our complex linetypes:

 

start the -style command

? to get list of all style in use

* (to return all results of styles)

lisp needs to then search the resulting list of styles and fonts for any font in use called ltypeshp.shx

replace all these fonts with simplex.shx

 

thats it! any help would be greatly appreciated

 

Cheers!

-Tom

 

0 Likes
933 Views
4 Replies
Replies (4)
Message 2 of 5

hmsilva
Mentor
Mentor

@Anonymous wrote:

LIke the topic says. I am 95% there, but i do not know all the getvar lisp coding

I want this lisp to be able to run on our consultants' files that are dumping out our complex linetypes:

 

start the -style command

? to get list of all style in use

* (to return all results of styles)

lisp needs to then search the resulting list of styles and fonts for any font in use called ltypeshp.shx

replace all these fonts with simplex.shx

 

thats it! any help would be greatly appreciated

 

Cheers!

-Tom

 


Hello Tom and welcome to the Autodesk Community!

 

Perhaps something like this:

 

(vl-load-com)
;; To replace font file in a text style.
;; usage
;; (repl_font "ltypeshp.shx" "simplex.shx")
(defun repl_font (old new /)
  (setq acdoc (vla-get-activedocument (vlax-get-acad-object))
        stls  (vla-get-textstyles acdoc)
  )
  (if (or (setq file (findfile new))
          (setq file (findfile (strcat (getenv "systemroot") "\\Fonts\\" new)))
      )
    (vlax-for stl stls
      (if (= (vla-get-fontfile stl) old)
        (vla-put-fontfile stl file)
      )
    )
  )
)

 

 

Hope this helps,
Henrique

EESignature

Message 3 of 5

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

....

I want this lisp to be able to run on our consultants' files that are dumping out our complex linetypes:

 

start the -style command

? to get list of all style in use

* (to return all results of styles)

lisp needs to then search the resulting list of styles and fonts for any font in use called ltypeshp.shx

replace all these fonts with simplex.shx

.... 


Wait a minute....  Are you talking about linetypes or text styles?  You seem to have elements of both mixed together.  Anything that includes ltypeshp.shx is going to be a complex linetype definition with embedded shapes -- that shape file is not a text font file and can't be used in a text style definition.  But simplex.shx is a text font file, and is not going to work as a source for shapes used in complex linetypes.  They may both be .shx filetypes, but they're not interchangeable [unless somehow you have really significantly altered AutoCAD's original files].

Kent Cooper, AIA
Message 4 of 5

Anonymous
Not applicable

Kent, you may be onto something. And i appreciate the warning.

 

What we want to use mainly are the linetypes:

Fenceline1  ---0----0----0----

Fenceline2 ----[]----[]-----[]-----

zigzag        ^^^^^^^^^^    

 

these linetypes are defined in our acad.lin file and they pull from an ltypeshp.shx file

 

some consultants we get files from use ltypeshp.shx as a font style and it is defined as such in their FONT styles. When we open their files, it corrupts our own acad.lin file so that those 3 styles listed above that we use a lot somehow lose their definitions.  

 

We read from Autodesk that the solution was to change ltypeshp.shx font defintions to simplex.shx definitions and it would fix this error.

LINK TO HELP FROM AUTOCAD

 

If you know of another fix, or know what the root of the problem is, i'd love to hear them. Without know where this is coming from, it is hard to isolate and fix the problem. 

 

thanks in advance

-Tom

Message 5 of 5

anatolyn
Explorer
Explorer

(defun C:cff ()
(vl-load-com)
;; To replace font file in a text style.
(defun repl_font (old new /)
(setq acdoc (vla-get-activedocument (vlax-get-acad-object))
stls (vla-get-textstyles acdoc)
)
(if (or (setq file (findfile new))
(setq file (findfile (strcat (getenv "systemroot") "\\Fonts\\" new)))
)
(vlax-for stl stls
(if (= (vla-get-fontfile stl) old)
(vla-put-fontfile stl file)
)
)
)
)
(repl_font "ltypeshp.shx" "simplex.shx")
)

0 Likes