Author Topic: Possible to Change .PAT Path Temporarily  (Read 1529 times)

0 Members and 1 Guest are viewing this topic.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Possible to Change .PAT Path Temporarily
« on: February 17, 2013, 04:39:38 AM »
Company has a structure of support files and a .pat file on its network.  It appears something on our network, or our virus software, is causing an error to pop up once in a while "can't read hatch pattern", which stops batch plotting, and causes issues when it pops up during hatching. When the PAT is copied to user drive, the network guy says the problem no longer occurs. 

I don't want to change the support path structure the company put in place, but would like to make my machine reference a .PAT file on my machine, rather than the one on the network so I can stop getting this error. Is this possible?

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Possible to Change .PAT Path Temporarily
« Reply #1 on: February 17, 2013, 06:22:57 AM »
You'd need to rearrange your support folder search paths. Adding / removing / shifting some folders into new positions. Remember acad searches through that set of folders for a particular file, the first one it finds is the one it uses - so the order of your SFSP has an effect if there are 2 or more copies of the same file.

To modify the SFSP through lisp you could use my code:
Code - Auto/Visual Lisp: [Select]
  1. ;;; -------------------------------------------------------------------------------------
  2. ;;;    SupportPaths.lsp v0.1
  3. ;;;    Copyright© 2013-01-10
  4. ;;;    Irné Barnard
  5. ;;;    Contact: irneb@users.sourceforge.net
  6. ;;; -------------------------------------------------------------------------------------
  7.  
  8. ;;; Clean a path string
  9. (defun Path:Clean (path) (vl-string-translate "/" "\\" (vl-string-right-trim "/\\" path)))
  10.  
  11. ;;; Get a list of paths from the support folder search path
  12. (defun SFSP:Get  (/ sp p)
  13.   (setq p  0
  14.         sp (getenv "ACAD"))
  15.   (while (setq p (vl-string-search ";" sp p)) (setq sp (vl-string-subst "\" \"" ";" sp p)))
  16.   (mapcar 'Path:Clean (read (strcat "(\"" sp "\")"))))
  17.  
  18. ;;; Set the support folder search path to a list of paths
  19. (defun SFSP:Set  (paths /)
  20.   (setenv "ACAD"
  21.           (vl-string-right-trim
  22.             ";"
  23.             (apply 'strcat (mapcar (function (lambda (path) (strcat (Path:Clean path) ";"))) paths)))))
  24.  
  25. ;;; Append a list of paths to the support folder search path
  26. (defun SFSP:Append  (paths / sp spU sU p)
  27.   (setq spU   (mapcar 'strcase (setq sp (reverse (SFSP:Get))))
  28.         paths (mapcar 'Path:Clean paths))
  29.   (foreach path  paths
  30.     (if (setq p (vl-position (setq sU (strcase path)) spU))
  31.       (setq sp  (vl-remove (nth p sp) sp)
  32.             spU (vl-remove (nth p spU) spU)))
  33.     (setq sp  (cons path sp)
  34.           spU (cons sU spU)))
  35.   (SFSP:Set (reverse sp)))
  36.  
  37. ;;; Prepend a list of paths to the support folder search path
  38. (defun SFSP:Prepend  (paths / sp spU sU p)
  39.   (setq spU   (mapcar 'strcase (setq sp (SFSP:Get)))
  40.         paths (mapcar 'Path:Clean (reverse paths)))
  41.   (foreach path  paths
  42.     (if (setq p (vl-position (setq sU (strcase path)) spU))
  43.       (setq sp  (vl-remove (nth p sp) sp)
  44.             spU (vl-remove (nth p spU) spU)))
  45.     (setq sp  (cons path sp)
  46.           spU (cons sU spU)))
  47.   (SFSP:Set sp))
  48.  
  49. ;;; Remove a list of paths from the support folder search path
  50. (defun SFSP:Remove (paths / sp spU p)
  51.   (setq spU   (mapcar 'strcase (setq sp (SFSP:Get)))
  52.         paths (mapcar 'Path:Clean (reverse paths)))
  53.   (foreach path  (mapcar 'strcase paths)
  54.     (if (setq p (vl-position path spU))
  55.       (setq sp  (vl-remove (nth p sp) sp)
  56.             spU (vl-remove (nth p spU) spU))))
  57.   (SFSP:Set sp))
  58.  
  59. ;;; Insert a list of paths into a position in the support folder search path
  60. (defun SFSP:Insert  (paths index / p sp spU)
  61.   (setq spU   (mapcar 'strcase (setq sp (SFSP:Get)))
  62.         paths (mapcar 'Path:Clean paths))
  63.   (foreach path  (mapcar 'strcase paths)
  64.     (if (setq p (vl-position path spU))
  65.       (progn (if (< p index)
  66.                (setq index (1- index)))
  67.              (setq sp  (vl-remove (nth p sp) sp)
  68.                    spU (vl-remove (nth p spU) spU)))))
  69.   (setq spU nil
  70.         p   0)
  71.   (while (and sp (< p index))
  72.     (setq spU (cons (car sp) spU)
  73.           sp  (cdr sp)
  74.           p   (1+ p)))
  75.   (SFSP:Set (append (reverse spU) paths sp)))

Another alternative might be to keep all your PC's using local paths only. But then having a program or BAT script copy the "new" versions from your server periodically. E.g. you might have a login script which copies and overwrites the files from the server into your support paths. Or you could use some program which synchronizes the files from the server - a very simple yet effective one I've used before is Karen's Replicator.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: Possible to Change .PAT Path Temporarily
« Reply #2 on: February 18, 2013, 05:52:22 AM »
Thanks irneb! I was hoping that I'd be able to force ACAD to reference my own path after everything has been loaded... doesn't appear possible :/