Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp file to check if files exist if not check go to next command

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
3789 Views, 5 Replies

Lisp file to check if files exist if not check go to next command

Is there a way of checking if a file/directory exists if it does do something if not go to next command ? I have got a lisp file that set's up the file paths and loads a enterprise customization file but there are paths that are different depending on where things are installed e.g. different for 64bit to 32bit and there are 2 different install folder I know that it can be done in a batch file to run things but that doesnt help i need it to run from within autocad for it to setup the support paths Using profiles is not an option because we dont want to remove the tools that the users has got loaded on there profile unless they are using the unnamed profile there stuff doesnt come though e.g. tool bars
5 REPLIES 5
Message 2 of 6
hmsilva
in reply to: Anonymous

Welcome to the Autodesk Discussion Groups, makepeace1

 

Try

 

(if (findfile "c:/your/directory/path")
  (do something);; if true
  (go to next command);; if not
  )

 

HTH

Henrique

EESignature

Message 3 of 6
Anonymous
in reply to: hmsilva

Just thougth i would put this inacse somone else was trying to do this but this is how i got it to add the support paths if the file did exist

 

(vl-load-com)(setq *files* (vla-get-Files (vla-get-Preferences (vlax-get-acad-object))))
(if (findfile "\\Program Files\\folder1\\Acad")
(vla-put-SupportPath *files* (strcat (vla-get-SupportPath *files*)
";"
"\\Program Files\\folder1\\acad;"
"\\Program Files\\folder2\\acad;"
 (princ "not there");; if not

Message 4 of 6
gccdaemon
in reply to: Anonymous

That's a great idea to autoload that routine. I've get several individuals who are on laptops. All our standards are located on our server, and if the take the laptops home, a lot of customizations get blitzed because they don't connect to the VPN first. Could you supply your routine? I would like to modify what you have to check file dates and copy newer files from the server to a local folder on their their drives when they load autocad.

Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
Message 5 of 6
Lee_Mac
in reply to: Anonymous


@Anonymous wrote:

..this is how i got it to add the support paths if the file did exist


You may find these functions of interest in this respect: Support File Search Path Functions

 

Lee

Message 6 of 6
Anonymous
in reply to: Anonymous

This is what i did to get it working for me

 

(vl-load-com)(setq *files* (vla-get-Files (vla-get-Preferences (vlax-get-acad-object))))
(if (findfile "\\Program Files\\folder1\\Acad")
(vla-put-SupportPath *files* (strcat (vla-get-SupportPath *files*)
";"
"\\Program Files\\folder1\\acad;"
"\\Program Files\\folder2\\acad;"
 (princ "not there");; if not

 

(vl-load-com)(setq *files* (vla-get-Files (vla-get-Preferences (vlax-get-acad-object))))
(if (findfile "\\Program Files\\diffrentfolder1\\Acad")
(vla-put-SupportPath *files* (strcat (vla-get-SupportPath *files*)
";"
"\\Program Files\\diffrentfolder1\\acad;"
"\\Program Files\\diffrentfolder2\\acad;"
 (princ "not there");; if not

 

 

Also did the same with the enterprise load

 

(vl-load-com)(setq *files* (vla-get-files (vla-get-preferences (vlax-get-acad-object))))
(if (findfile "\\Program Files\\Afolder\\Acad")
(vla-put-EnterpriseMenuFile *files* "\\Program Files\\AFOLDER\\Acad\\CUIXFILE")
(princ "not there");; if not
)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost