Author Topic: Support file search path  (Read 5056 times)

0 Members and 1 Guest are viewing this topic.

CHulse

  • Swamp Rat
  • Posts: 504
Support file search path
« on: May 22, 2018, 12:53:14 PM »
Does anyone here know a way to add new locations to the support file search path via lisp? We use a few network locations for support files and occasionally the network connection is lost. If a user opens cad without that connection, the entry in the support file path list is lost also.
Was hoping to make a lisp to add them back easily.

Any direction would be appreciated.

Thanks
Cary Hulse
Urban Forestry Manager
Wetland Studies and Solutions

Civil 3D 2020 & 2023

Crank

  • Water Moccasin
  • Posts: 1503
Re: Support file search path
« Reply #1 on: May 22, 2018, 01:47:05 PM »
here and here.
Vault Professional 2023     +     AEC Collection

CHulse

  • Swamp Rat
  • Posts: 504
Re: Support file search path
« Reply #2 on: May 22, 2018, 02:05:07 PM »
Awesome, thanks.
Apparently I didn't spend enough time searching before I posted.
Cary Hulse
Urban Forestry Manager
Wetland Studies and Solutions

Civil 3D 2020 & 2023

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England

BIGAL

  • Swamp Rat
  • Posts: 1398
  • 40 + years of using Autocad
Re: Support file search path
« Reply #4 on: May 22, 2018, 09:29:19 PM »
Another example.

Code: [Select]
; resets the paths usefull for update versions of Autocad
; by A Houston 2011
; This sets a reference to the install path of your product
; the gets are their for info maybe other use
; use this to find other settings
;(vlax-dump-object (vla-get-files (vla-get-preferences (vlax-get-Acad-object))) T)



(vl-load-com)
(defun setpaths ( / *files* doc)
; make temp directory
(if (vl-file-directory-p "C:\\Acadtemp\\")
(Princ "Acadtemp exists")
(vl-mkdir "C:\\AcadTEMP\\")
)

(setq *files*  (vla-get-files  (vla-get-preferences (vlax-get-Acad-object))))

; savepath
;(vla-get-AutoSavepath *files*)
(vla-put-AutoSavepath *files* "C:\\AcadTemp")

; custom icons
;(vla-get-CustomIconPath *files*))
(vla-put-CustomIconPath *files* "P:\\Autodesk\\ICONS")

; printers config
;(vla-get-PrinterConfigPath *files*)
(vla-put-PrinterConfigPath *files* "P:\\AutoDESK\\Plotting\\Plot Styles 2011")

; printers style sheet
;(vla-get-PrinterStyleSheetPath *files*)
(vla-put-PrinterStyleSheetPath *files* "P:\\AutoDESK\\Plotting\\Plot Styles")

; printer drv's
;(vla-get-PrinterDescPath *files*)
(vla-put-PrinterDescPath *files* "P:\\AutoDESK\\Plotting\\Drv")

; print spooler
;(vla-get-PrintSpoolerPath *files*)
(vla-put-PrintSpoolerPath *files* "C:\\AcadTemp\\")

; template  path
;(vla-get-TemplateDwgPath *files*)
(vla-put-TemplateDwgPath *files* "P:\\Autodesk\\c3d Templates")

; template location
;(vla-get-QnewTemplateFile *files*)
(vla-put-QnewTemplateFile *files* "P:\\Autodesk\\c3d Templates\\XXXX.dwt")

;make new support paths exist + new
(setq paths (vla-get-SupportPath *files*))
(setq XXXXpaths "P:\\autodesk\\supportfiles;P:\\autodesk\\lisp;P:\\autodesk\\fonts;P:\\autodesk\\hfs fonts;")
(setq newpath (strcat XXXXpaths paths))
(vla-put-SupportPath *files* newpath)

; Tempdirectory
;(vla-get-TempFilePath *files*))
(vla-put-TempFilePath *files* "C:\\AcadTemp\\")

;   PlotLogFilePath = "C:\\Documents and Settings\\BIGAL.XXXX-AD\\localsettings\\application data\\autodesk\\c3d 2011\\enu\\"
(vla-put-PlotLogFilePath *files* "C:\\AcadTemp\\")

;   LogFilePath = "C:\\Documents and Settings\\BIGAL.XXXX-AD\\localsettings\\application data\\autodesk\\c3d 2011\\enu\\"
(vla-put-LogFilePath *files* "C:\\AcadTemp\\")


; xref temp path
;(vla-get-TempXrefPath *files*))
(vla-put-TempXrefPath *files* "C:\\AcadTemp\\")

; end use of *files*
)
(setpaths)

; exit quitely
(princ "All Done")
A man who never made a mistake never made anything

CHulse

  • Swamp Rat
  • Posts: 504
Re: Support file search path
« Reply #5 on: May 23, 2018, 08:41:59 AM »
http://lee-mac.com/addremovesupportpaths.html

Thanks Lee. I think I'll be using that. Appreciate your great work!
Cary Hulse
Urban Forestry Manager
Wetland Studies and Solutions

Civil 3D 2020 & 2023

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
Re: Support file search path
« Reply #6 on: May 23, 2018, 10:26:04 AM »
I may be missing something but isn't it as simple as:
Code - Auto/Visual Lisp: [Select]
  1. (setenv "ACAD" (strcat <PATHSTR> (getenv "ACAD")))
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: Support file search path
« Reply #7 on: May 23, 2018, 02:26:05 PM »

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Support file search path
« Reply #8 on: May 23, 2018, 03:14:22 PM »
I may be missing something but isn't it as simple as:
Code - Auto/Visual Lisp: [Select]
  1. (setenv "ACAD" (strcat <PATHSTR> (getenv "ACAD")))

A little more complicated when you start considering outcomes.  For example, what happens if the path is already present?  What if you want the search path somewhere in the middle of the existing paths?
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

JohnK

  • Administrator
  • Seagull
  • Posts: 10605
Re: Support file search path
« Reply #9 on: May 23, 2018, 04:13:52 PM »
I may be missing something but isn't it as simple as:
Code - Auto/Visual Lisp: [Select]
  1. (setenv "ACAD" (strcat <PATHSTR> (getenv "ACAD")))

A little more complicated when you start considering outcomes.  For example, what happens if the path is already present?  What if you want the search path somewhere in the middle of the existing paths?
Not enough information in the OP but...I don't care if the path already exists (in this context or/and unless you have 50 duplicates). But you shouldn't be calling this type of code every time you open a drawing, for example. Besides, AutoCAD (used to--at least) stop once it found the first occurrence of what it was looking for. Now if you want to re-order the list that takes a bit more. But I'm sure you can find plenty of examples here (I'm sure I've even done that task once or a thousand times in the past so I probably even have code posted here to do that-and I'm a dummy) but that wasn't the question; the OP wanted to know how to add to the path variable (-i.e. hence the "get path, append new to it, set the path" response from me).
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

rkmcswain

  • Swamp Rat
  • Posts: 978
Re: Support file search path
« Reply #10 on: May 24, 2018, 07:37:41 AM »
Quote from: CHulse
Does anyone here know a way to add new locations to the support file search path via lisp? We use a few network locations for support files and occasionally the network connection is lost. If a user opens cad without that connection, the entry in the support file path list is lost also.
Was hoping to make a lisp to add them back easily.


We use a local "acad.lsp" (located in \Program Files\Autodesk\AutoCAD 2019\Support), which loads the network version of "acad.lsp".
The network copy in turn sets the support file search paths (SFSP), and the network location of this "acad.lsp" gets put at the top of the list, forcing this same "acad.lsp" to load the next time.

If, by chance, the network resource is not available at ACAD startup time, then the local "acad.lsp" fires, and informs the user that the network resource is N/A.
So at this point, like you say, those network paths are dropped from the SFSP.
Say the network resource comes back online, and the user restarts ACAD.
The local "Acad.lsp" fires again, this time finding the network "acad.lsp", which loads, and voila, everything is back to normal, with no human intervention.

ScottMC

  • Newt
  • Posts: 191
Re: Support file search path
« Reply #11 on: May 24, 2018, 10:45:15 AM »
Understandable why my Win7Pro 64 was unhelpful in installing my A2K but, to complicate things, windows refused my "New/Open" window of my "Start-in:" folder till.. went and took a chance and copied my A2K "Autodesk Shared" DLL etc files into my main CAD dwg folder, changed the "Start-in:" to that main folder and finally, it works!! "Select file to open" image below shows the "Look in Favorites" which still doesn't work.. only challenge left but don't miss it.
« Last Edit: May 26, 2018, 02:22:54 PM by ScottMC »

ahsattarian

  • Newt
  • Posts: 112
Re: Support file search path
« Reply #12 on: January 23, 2021, 01:13:07 PM »
This may help u  :



Code - Auto/Visual Lisp: [Select]
  1. (defun c:a ()
  2.   (print (acet-pref-supportpath-list))
  3.   (defun sfspli ()
  4.     ;|  http://paracadd.com/lisp/-access-to-the-options-dialog-properties.LSP  |;
  5.     (print (vla-get-supportpath (vla-get-files (vla-get-preferences (vlax-get-acad-object))))) ;|  http://paracadd.com/lisp/SupportPaths.lsp  |;
  6.     (setq str (getenv "ACAD"))
  7.     (setq li nil)
  8.     (setq txt "")
  9.     (setq n (strlen str))
  10.     (setq i 0)
  11.     (repeat n
  12.       (setq i (1+ i))
  13.       (setq let (substr str i 1))
  14.       (cond ((/= (ascii let) 59) (setq txt (strcat txt let))))
  15.       (cond ((= (ascii let) 59) (setq li (append li (list txt))) (setq txt "")))
  16.     )
  17.     (cond ((/= txt "") (setq li (append li (list txt)))))
  18.     (setq k 0)
  19.     (foreach a li
  20.       (setq k (1+ k))
  21.       (princ "\n  ")
  22.       (cond ((< k 10) (princ "0")))
  23.       (princ k)
  24.       (princ "  --->  ")
  25.       (princ a)
  26.     )
  27.   )
  28.   (princ "\n\n >>>>>>>>>>> Before : >>>>>>>>>>> \n")
  29.   (sfspli)
  30.   (setq shl (vla-getinterfaceobject (vlax-get-acad-object) "shell.application"))
  31.   (setq fld (vlax-invoke-method shl 'browseforfolder 0 "Select a folder" 512 ""))
  32.   (setq ad (strcat (vlax-get-property (vlax-get-property fld 'self) 'path) "\\"))
  33.   (setq li1 (cdr (cdr (vl-directory-files ad "*.*" -1))))
  34.   (setq li2 nil)
  35.   (foreach a li1 (setq b (strcat ad a)) (setq li2 (append li2 (list b))))
  36.   (setq li3 (acad_strlsort li2))
  37.   (setq li0 nil)
  38.   (foreach a li (cond ((not (member a li3)) (setq li0 (append li0 (list a))))))
  39.   (setq li li0)
  40.   (setq li4 (reverse li3))
  41.   (foreach a li4 (cond ((not (member a li)) (setq li (append (list a) li)))))
  42.   (setq str "")
  43.   (foreach a li (setq str (strcat str a ";")))
  44.   (setq str (substr str 1 (1- (strlen str))))
  45.   (setenv "ACAD" str)
  46.   (princ "\n\n >>>>>>>>>>> After : >>>>>>>>>>> \n")
  47.   (sfspli)
  48.   (textscr)
  49.   (princ)
  50. )