Author Topic: findfile not working support file path. Profile path issue I'm guessing.  (Read 1360 times)

0 Members and 1 Guest are viewing this topic.

damn

  • Mosquito
  • Posts: 15
Hi,

Due to time constraints I have to hard code known file paths into some code as the findfile function does not work newly imported profiles.  I set the Support File Search Paths.  I export it to a .arg file.  For testing I remove the profile (delete it in CAD).  I re-import it.  I confirm the Support File Search Paths are set in the newly imported profile.  findfile fails to find the file(s) until I re-browse to the identical Support file path.  As the file paths are known on ea pc I'm rolling the routines with hard coded the file paths in rather than use findfile. I do notice when I re-import the profile in the file paths are all in lowercase until re-browse.  Why do I use findfile?  As I do testing of my code, I have a testing profile with different file paths.   Anyone have similar issues?
And saying that I have no other use for .arg file.

BIGAL

  • Swamp Rat
  • Posts: 1396
  • 40 + years of using Autocad
You can amend the search file paths without using an arg, just do directly.

Code: [Select]
(setq *files*  (vla-get-files  (vla-get-preferences (vlax-get-Acad-object))))

;make new support paths exist + new
(setq paths (vla-get-SupportPath *files*))
(setq xxxxpaths "P:\\autodesk\\supportfiles;P:\\autodesk\\lisp;P:\\autodesk\\fonts;")
(setq newpath (strcat xxxxpaths paths))
(vla-put-SupportPath *files* newpath)
A man who never made a mistake never made anything

tombu

  • Bull Frog
  • Posts: 288
  • ByLayer=>Not0
I've rarely used findfile as all my code is located in folders AutoCAD expects it in.
Pay attention to how AutoCAD prefers capitalization to be used as it's changed a few times in different versions.
Besides the Support File Search Path you may need to add folders to Trusted Paths.
Check to see if the folder is in the path before adding it.
Lots of ways to do this by Lee Mac and others: http://lee-mac.com/addremovesupportpaths.html
Example from my Acad.lsp:
Code: [Select]
(princ "\n\"Acad.lsp\" loading. ")
(vl-load-com)
(defun AddSupportPath (dir / Cpath Uname)
  (setq Cpath (getenv "ACAD") Uname (getenv "Username") dir (vl-string-subst Uname "%Username%" dir))
  (or (vl-string-search (strcase dir) (strcase Cpath)) (setenv "ACAD" (strcat Cpath ";" dir)))
  (princ "\nCpath = ")(princ (getenv "ACAD"))
  (princ "\ndir = ")(princ dir)
  (princ)
)
(AddSupportPath (strcat"D:\\Users\\" (getenv "Username") "\\AppData\\Roaming\\Autodesk\\VLisp"))
(AddSupportPath (strcat"D:\\Users\\" (getenv "Username") "\\AppData\\Roaming\\Autodesk\\Icons"))
(AddSupportPath "G:\\ENGDESGN\\BeaufordT\\Autocad\\Application Data\\Customization")
(AddSupportPath "G:\\ENGDESGN\\BeaufordT\\Autocad\\Application Data\\Fonts")

(defun AddTrustedPath (dir / trusted Uname)
  (setq trusted (getvar 'trustedpaths) Uname (getenv "Username") dir (vl-string-subst Uname "%Username%" dir))
  (or (vl-string-search dir trusted) (setvar 'trustedpaths (strcat trusted ";" dir)))
  (princ)
)
(AddTrustedPath (strcat (getenv "userprofile") "\\AppData\\Roaming\\Autodesk\\VLisp"))
« Last Edit: July 08, 2020, 06:57:59 AM by tombu »
Tom Beauford P.S.M.
Leon County FL Public Works - Windows 7 64 bit AutoCAD Civil 3D

JohnK

  • Administrator
  • Seagull
  • Posts: 10603
Profile update routine I penned a long time ago.
https://www.theswamp.org/index.php?topic=14917.msg180480#msg180480
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

dgorsman

  • Water Moccasin
  • Posts: 2437
I frequently use (findfile ...) where proceding if it doesn't exist would be bad.  Multiple calls in succession take longer, and the core function doesn't have nested folder search capability, so I have a wrapper function which does the latter as well as cache the result to be used later instead of an actual search.

I'm also moving away from using the SFSP as much, as the number of required paths has grown a bit unwieldy.
If you are going to fly by the seat of your pants, expect friction burns.

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