Am I understanding you correctly, that you have files/folders on your USB drive that are being deleted on a daily basis when you connect it to your work computer/network?No. The files/folders on my USB drive haven't lost and the only the paths to the USB disappeared in the "Options".
Am I understanding you correctly, that you have files/folders on your USB drive that are being deleted on a daily basis when you connect it to your work computer/network?No. The files/folders on my USB drive haven't lost and the only the paths to the USB disappeared in the "Options".
As the result, all routines resided on my USB are not functioning.
Is there anyway to autoload the preset SFSP or the only portion of the paths to my USB by lisp?
;;lee macs code
(defun _SFSP+ ( lst / str )
(setenv "ACAD"
(strcat (setq str (vl-string-right-trim ";" (getenv "ACAD"))) ";"
(apply 'strcat
(mapcar (function (lambda ( x ) (strcat x ";")))
(vl-remove-if
(function
(lambda ( x )
(or (vl-string-search (strcase x) (strcase str))
(not (findfile x))
)
)
)
(mapcar
(function
(lambda ( x )
(vl-string-right-trim "\\" (vl-string-translate "/" "\\" x))
)
)
lst
)
)
)
)
)
)
)
useage:
(_sfsp+ '("F:\\ACAD"
"F:\\ACAD\\acad2014"
"F:\\ACAD\\acad2014\\lisp"
"F:\\ACAD\\acad2014\\menu"
"F:\\ACAD\\acad2014\\menu\\bmp"
"F:\\ACAD\\acad2014\\dcl"
"F:\\ACAD\\acad2014\\scripts"
"F:\\ACAD\\acad2014\\templates"
"F:\\ACAD\\acad2014\\hatch pats"
"F:\\ACAD\\BLOCKS"
"F:\\ACAD ARCHIVE"
)
)
This seemed relevant:Code: [Select](defun c:SFSP+ (/ *error*)
(vl-load-com)
(defun *error* (msg)
(if oShell
(setq oShell (vlax-release-object oShell)))
(cond ((not msg)) ; Normal exit
((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit)
((princ (strcat "\n** Error: " msg " ** ")))) ; Fatal error, display it
(princ))
((lambda (acApp / oShell oFolder acDoc acFiles path oldPath)
(if
(and
(setq oShell
(vlax-get-or-create-object "Shell.Application"))
(setq oFolder
(vlax-invoke
oShell 'BrowseForFolder (vla-get-hwnd acApp)
"Select a folder to add to SFSP:" 0)))
(if
(not
(vl-string-search
(strcase
(setq path
(strcat
(vlax-get-property
(vlax-get-property oFolder 'Self)
'Path)
";")))
(strcase
(setq oldPath
(strcat
(vl-string-right-trim
";"
(vla-get-supportpath
(setq acFiles
(vla-get-files
(vla-get-preferences
acApp)))))
";")))))
(progn
(vla-put-supportpath acFiles (strcat oldPath ";" path))
(*error* nil))
(*error* "Path already exists in SFSP"))
(cond
(oShell (*error* nil))
((*error* "Unable to create Shell.Application Object")))))
(vlax-get-acad-object)))
I have external hard drive that I change the drive letter to match server at work I plug into my laptop that matches folder structure at work.
If you ever start AutoCAD and the USB is not plugged in and it cannot find the paths it will remove them, at least that has been my experience.
(defun c:Y_Paths2 ()
(vl-load-com)
(vl-vbaload "Y:\\Support\\Apps\\VBA\\Y_DirPaths2.dvb")
(vl-vbarun "Y_SupportPath2")
(vl-vbarun "Y_AutosavePath2")
(vl-vbarun "Y_TemplatePath2")
(command "menuload" "y:\\Support\\Menu\\Cad_STD.mnc")
)
Sub Y_SupportPath2()
Dim preferences As AcadPreferences
Dim currSupportPath As String
Dim newSupportPath As String
Set preferences = ThisDrawing.Application.preferences
currSupportPath = preferences.Files.SupportPath
newSupportPath = currSupportPath + ";Y:\Support\Startup;Y:\Support\Apps;Y:\Support\Blocks;Y:\Support\Menu;Y:\Support\Apps\Testing"
preferences.Files.SupportPath = newSupportPath
End Sub
Sub Y_AutosavePath2()
Dim preferences As AcadPreferences
Dim currAutoSavePath As String
Dim newAutoSavePath As String
Set preferences = ThisDrawing.Application.preferences
newAutoSavePath = "Y:\Support\AutoSave"
preferences.Files.AutoSavePath = newAutoSavePath
End Sub
Sub Y_TemplatePath2()
Dim preferences As AcadPreferences
Dim currTemplateDWGPath As String
Dim newTemplateDWGPath As String
Set preferences = ThisDrawing.Application.preferences
newTemplateDWGPath = "Y:\Support\Dwg_Templates"
preferences.Files.TemplateDwgPath = newTemplateDWGPath
End Sub
...
<function definition for AddSupportPaths from JTB World>
...
(setq paths2Add '("E:\\Support\\Path1"
"E:\\Support\\Path2"
"E:\\Support\\Path3"))
(mapcar 'AddSupportPaths (vl-remove-if-not 'findfile paths2Add))
How can I insert the "S:\\" (the USB path) to the SFSP as the 2nd item in the list?
(vl-load-com)
;;function to accept a deliminated string <str> and the deliminator <delim>, and return a list of strings
(defun vl:string->list (str delim / lst loc)
(while (setq loc (vl-string-search delim str))
(setq lst (append lst (list (substr str 1 loc)))
str (substr str (1+ (+ loc (strlen delim)))))
)
(append lst (list str))
)
;;function to accept a list of strings <ls> and return a string deliminated by a deliminator <delim>
(defun vl:list->string (delim ls / out)
(setq out (apply 'strcat (mapcar (function (lambda (x) (strcat x delim))) ls)))
(if out (vl-string-right-trim delim out))
)
;;function to add a list item <newitem> to an existing list <alist> at <position>
(defun vl:nth-add (newitem alist position / i p)
(setq i -1 p -1)
(append (vl-remove-if (function (lambda (x) (<= position (setq p (1+ p))))) alist)
(list newitem)
(vl-remove-if (function (lambda (x) (> position (setq i (1+ i))))) alist)
)
)
;;function to return support paths as a list of strings
(defun getSupportPaths (/ )
(vl:string->list (vla-get-supportpath (vla-get-files (vla-get-preferences (vlax-get-acad-object)))) ";")
)
;;function to accept a list of support path strings, and apply them to the search path preferences
(defun setSupportPaths (pathlst /)
(vla-put-supportpath
(vla-get-files (vla-get-preferences (vlax-get-acad-object)))
(vl:list->string ";" pathlst)
)
)
;;main wrapper function to accept a path and desired hierachal location in the search path list.
;;if pathing already exists, then it will be relocated to new location.
(defun putSupportpath (newPath loc / paths)
;remove if found, so we can place in location where it needs to be
(setq paths (vl-remove (strcase newPath) (mapcar 'strcase (getsupportpaths))))
(setSupportPaths (vl:nth-add newPath paths loc))
)
;;call the main wrapper with required vars
;;function: putsupportpath <pathing> <index location>
(putsupportpath "S:\\" 1)
(princ)
How can I insert the "S:\\" (the USB path) to the SFSP as the 2nd item in the list?
Why don't you just pass the string returned by each 'Read-Line' call, to a parser sub-function, which returns a list of sub-strings:Code - Auto/Visual Lisp: [Select]
;; BlackBox, TheSwamp.org ;; Example: (BBOX:Parser "-" "dd-mm-yyyy") ;; Returns: ("dd" "mm" "yyyy") ) )
<snip>
... To break the string value into a list of strings (BBOX:Parser ";" <SFSP>), substitute, or reorder, or append as needed, and simply reassemble.