Hi
I've made a custom lisp-script to save my file to a new directory, make some changes, save it and open the old file. So far so good.
I've added it to APPLOAD (and bound it to a button). Works fine the first time, but when I want to run it the next time I get this error:
Command: _savefile ; error: no function definition: C:SAVEFILE
When I look in APPLOAD it looks fine, the lisp-file is still there but it still can't find the command.
What can be wrong here?
Thanks!
Solved! Go to Solution.
Solved by hmsilva. Go to Solution.
(vl-load-com) (defun c:savemyfile ( / ) (setq file (getvar "DWGNAME")) (setq path (getvar "DWGPREFIX")) (setq pathfile (strcat path file)) (setq newpathfile (strcat "c:\\newfolder\\" file)) (command "qsave") (vl-file-delete newpathfile) (princ) (command "_saveas" "2013" newpathfile) (command "PURGE" "ALL" "*" "N") (command "PURGE" "REGAPPS" "*" "N") (command "XREF" "D" "*") (command "qsave") (command "fileopen" pathfile) )
I changed the name before I posted it here, its really called something else that's not a system variable, but I didn't think too much before going with savefile =P I'll just edit that in my last post.
@Anonymous wrote:
I changed the name before I posted it here, its really called something else that's not a system variable, but I didn't think too much before going with savefile =P I'll just edit that in my last post.
Try changing your button macro to something like this
(if (not c:YourCommandName)(load "YourLispFileName"));YourCommandName;
HTH
Henrique
I think your lisp open the new drawing from a new path with same file name. You need to load your Lisp again in the new drawing file. Otherwise you can add your lisp file in "Startup suite".
Try this. it may work.
STM
Use (vla-open (vla-get-documents (vlax-get-acad-object)) pathfile 0) instead of (command "fileopen" pathfile)
Try this. It may work
STM
@Anonymous wrote:
.... it's not an option to only be able to have one document open at the time... Isn't there any other way to get it to work?
....
It needs SDI=1 because otherwise, a Lisp routine can't "survive" moving into a different drawing, which is what SAVEAS does. I would try this approach, which will not involve getting out of the drawing you're in, nor therefore getting back into it:
UNDO Mark;
Purges and Xref deletions;
Use the SAVE command [not to be confused with SAVEAS or QSAVE (the latter of which is what you get from ctrl-S and so-called "Save" menu items)] to the other location, which will make a new drawing file there, the same as the one you're in, without taking you into it, but will leave you in the drawing you're in;
UNDO Back to revert to before the Purges and Xref deletions.