AutoLISP: Purge Missing SHX files

If you have drawings that are constantly missing SHX (shape) files, the routine posted below is now your friend.

The routine was posted in the LISP forum at CADTutor at the following link. Please refer questions there.
http://www.cadtutor.net/forum/showthread.php?37306-remove-unknown-SHX-files&highlight=delete+shape+files

Here’s how:

  • PSHX <enter>

The result in the command line will show how many unresolved shape files were removed from the drawing.

Missing SHX 1 Missing SHX2Thanks for sharing this routine Kheylan


;; posted by: Kheylan
;; Downloaded from CADTutor forum
;; http://www.cadtutor.net/forum/showthread.php?37306-remove-unknown-SHX-files&highlight=delete+shape+files

(defun C:PSHX ()

  (vl-load-com)
  (vlax-for item
         (vla-get-textstyles
           (vla-get-ActiveDocument (vlax-get-acad-object))
         )
    (if
      (not
    (vl-filename-extension (setq fname (vla-get-fontfile item)))
      )
       (setq fname (strcat fname ".shx"))
    )
    (cond ((findfile fname) nil)
      ((findfile (strcat (getenv "WINDIR") "\\FONTS\\" fname))
       nil
      )
      (t
       (vla-put-fontfile item "ltypeshp.shx")
       (princ "\nChange ")
       (princ fname)
       (princ " on ltypeshp.shx")
      )
    )
  )
  (princ)
)
;(princ "\nPurge unreferenced shape files, Lisp Command : PSHX")
Advertisement

About AutoCAD Tips

This blog serves as a knowledge base for myself (and anyone else) so that I can reference tips & tricks that I have learned and also refer others to it as well. I hope that this blog helps you learn at least one tip to make your drafting/design experience better.
This entry was posted in AutoLISP, AutoLISP: Manage, Linetypes, Manage. Bookmark the permalink.

3 Responses to AutoLISP: Purge Missing SHX files

  1. MB says:

    Thank you very much!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s