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

Check if a file exists to choose YES in the SAVE

2 REPLIES 2
Reply
Message 1 of 3
gustavobernardi
667 Views, 2 Replies

Check if a file exists to choose YES in the SAVE

Hello, I'm creating a system that creates additional autosave files. In the first SAVE okay, the problem is when I save the file again, the prompt checks with yes and no if I want to overwrite the file. My wish is that if the file already exists can answer yes automatically. (defun salvameubackup() (setq ringobackupname (strcat (getvar "dwgprefix") "backup_"(getvar "dwgname"))) (command "._save" ringobackupname) ) TIA
2 REPLIES 2
Message 2 of 3

Try by changing the code like this.

 

(defun salvameubackup() 
(setq ringobackupname (strcat (getvar "dwgprefix") "backup_"(getvar "dwgname")))
(if (findfile ringobackupname);check if the file exists
(command "._save" ringobackupname "yes");if file exists then replace it
(command "._save" ringobackupname)
);if
);defun

 

Message 3 of 3

Here's what I do in a similar situation, which avoids the need to check whether the file exists:  I just include the "Yes" answer in the Save command.  The first time a drawing is saved that way, the command doesn't ask whether it should be replaced, the "Yes" goes in as if it were a command, and an unknown-command message goes by at the Command: prompt line, but it doesn't interfere with anything.  Then for all subsequent saves under the same name, the question is asked, and the "Yes" is there to answer it.

Kent Cooper, AIA

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

Post to forums  

Autodesk Design & Make Report

”Boost