MikeP Posted April 1, 2009 Posted April 1, 2009 I need an auto save lisp. It needs to load it self automatically every time I create a new drawing. I want it to run the "qsave" command every minuet. the autosave does not work like I want it to. and often I will loose work. Quote
MikeP Posted April 1, 2009 Author Posted April 1, 2009 how about saving every X number of commands? are you suggesting me saving every few commands or for a function for the lisp. if for the lisp that would be fine. Quote
Lee Mac Posted April 1, 2009 Posted April 1, 2009 Will save after 10 commands ~ just load it. (defun Make_Reactor () (vl-load-com) (if (not save:reactor) (setq save:reactor (vlr-command-reactor nil '((:vlr-commandWillStart . SvPrompt))))) (princ)) (Make_Reactor) (defun SvPrompt (Reac Args / doc) (or i (setq i 0)) (if (= i 10) (progn (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))) (vla-save doc) (vla-saveas doc (strcat (getvar "dwgprefix") (vla-get-name doc))) (setq i 0)) (setq i (1+ i))) (princ)) Quote
CmdrDuh Posted April 1, 2009 Posted April 1, 2009 I have a VBA function that saves every X commands, you specify, but it ignores pan zoom, and resets on qsave or saveas or save. Sorry, I dont use LISP very much Quote
Lee Mac Posted April 1, 2009 Posted April 1, 2009 I have a VBA function that saves every X commands, you specify, but it ignores pan zoom, and resets on qsave or saveas or save. Sorry, I dont use LISP very much Hmmm... thats a point - mine was just a "quick & dirty" LISP post as ppl say... haven't tested it in the situation of qsave, save, pan and zoom... could be interesting.. Quote
CmdrDuh Posted April 1, 2009 Posted April 1, 2009 Option Explicit Dim command_count As Long 'Used in AcadDocument_EndCommand function Private Sub AcadDocument_EndCommand(ByVal CommandName As String) '***Below code is to AUTO save the drawing every 25 commands, If ThisDrawing.GetVariable("DWGTITLED") = 1 Then 'don't use on new, unsaved drawings Select Case CommandName Case UCase("undo"), UCase("u"), UCase("zoom"), UCase("z"), UCase("pan") command_count = command_count Case UCase("QSAVE"), UCase("SAVE") command_count = 0 Case Else command_count = command_count + 1 If command_count = 25 Then 'change this to any number you want ThisDrawing.Save command_count = 0 End If End Select End If End Sub Quote
CmdrDuh Posted April 1, 2009 Posted April 1, 2009 Lee, do you know how to take what I posted and test? Quote
Lee Mac Posted April 1, 2009 Posted April 1, 2009 Lee, do you know how to take what I posted and test? I have never run a VBA function in my life - sorry Quote
MikeP Posted April 2, 2009 Author Posted April 2, 2009 Lee, do you know how to take what I posted and test? how do i run that as well and how does it function Quote
MikeP Posted April 2, 2009 Author Posted April 2, 2009 Will save after 10 commands ~ just load it. what do you mean just load it. do I have to enter a command name in each drawinging to start it or is it universal for every new drawing. where do I just load it. I normaly load things into "appload" Quote
CmdrDuh Posted April 2, 2009 Posted April 2, 2009 Open Autocad, then hit Alt-F11 to open the VBA IDE which is where we will cut and paste. Paste the code in the ThisDrawing area. Save as Acad.dvb in you search path, and then it just tweaking to your number of preferedd commands Quote
CmdrDuh Posted April 2, 2009 Posted April 2, 2009 The Acad.dvb file will autoload, and run automatically. Quote
Lee Mac Posted April 2, 2009 Posted April 2, 2009 The Acad.dvb file will autoload, and run automatically. Many thanks David - thats a great explanation, now I know for future reference. what do you mean just load it. do I have to enter a command name in each drawinging to start it or is it universal for every new drawing. where do I just load it. I normaly load things into "appload" Just load the Reactor as you would a normal LISP - either in the appload, start-up suite or ACADDOC.lsp. You needn't invoke the LISP with any command, it will run automatically when needed. (hence the name reactor). Quote
MikeP Posted April 2, 2009 Author Posted April 2, 2009 Many thanks David - thats a great explanation, now I know for future reference. Just load the Reactor as you would a normal LISP - either in the appload, start-up suite or ACADDOC.lsp. You needn't invoke the LISP with any command, it will run automatically when needed. (hence the name reactor). when i saved your code, do i need save it as a .lsp or a .txt then load it in the appload? Quote
MikeP Posted April 2, 2009 Author Posted April 2, 2009 Open Autocad, then hit Alt-F11 to open the VBA IDE which is where we will cut and paste. Paste the code in the ThisDrawing area. Save as Acad.dvb in you search path, and then it just tweaking to your number of preferedd commands when ever i do that, it freezes cad for a while then it crashes Quote
CmdrDuh Posted April 2, 2009 Posted April 2, 2009 that is very bizarre, I would have yout IT people look at your machine to see if they are disableing it somehow, or you might not have it installed. When autocad was installed, they might not have chosen FULL install. Quote
CmdrDuh Posted April 2, 2009 Posted April 2, 2009 when i saved your code, do i need save it as a .lsp or a .txt then load it in the appload? Save it as a LSP file Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.