Author Topic: CMDACTIVE/Reactor Question  (Read 5912 times)

0 Members and 1 Guest are viewing this topic.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: CMDACTIVE/Reactor Question
« Reply #15 on: February 23, 2010, 05:25:19 PM »

Do you want to keep each backup version ?

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: CMDACTIVE/Reactor Question
« Reply #16 on: February 23, 2010, 05:39:09 PM »

Have a play with something like this :-

Code: [Select]
;;; KDUB_AUTO-SaveTime.lsp
;;; add this to your .MNL file
;;; (or (VL-SYMBOL-VALUE  'kdub:AutoSave) (load "KDUB_AUTO-SaveTime.LSP") )
;;;
(vl-load-com)
(setvar "SaveTime" 10)

(princ (strcat "\n'KDUB_AUTO-SaveTime' loaded, SaveTime set to " (itoa (getvar "SaveTime")) ".\n"))


;; based on Code by James Allen  http://discussion.autodesk.com/forums/message.jspa?messageID=4289494#4289494
;; Revised by KDUB@theSwamp 2010.02.24
;;;  AutoSave makes a copy of AutoCAD's current autosave file.
;;
(defun kdub:autosave (rxrnm           cmdinf          /
                      activedocument  date            savefilename
                      autosavefilename                juliansavetime
                      mwe:getvar
                     )
  ;;---------------------------------------------------------------------- 
;;; Getvar using ActiveX
  (defun mwe:getvar (arglst)
    (vlax-invoke activedocument 'getvariable arglst)
  )
  ;;----------------------------------------------------------------------
  (setq activedocument (vlax-get (vlax-get-acad-object) 'activedocument)
        date           (mwe:getvar "date")
        savefilename   (findfile (mwe:getvar "savefile"))
  )
  (if (and savefilename asv:timetosave (>= date asv:timetosave))
    (progn
      (setq autosavefilename
             (strcat
               (mwe:getvar "savefilepath")
               "\\AutoSave "
               (vl-filename-base (mwe:getvar "dwgname"))
               "_"
               (rtos (* (mwe:getvar "cdate") 1000000) 2 0)
               ".dwg"
             )
      )
      (prompt
        (strcat "\nKDUB_AUTO-SaveTime: Backing up autosave file ...\n"
                autosavefilename
                "\n"
        )
      )
      (if (findfile autosavefilename)
        (vl-file-delete autosavefilename)
      )
      (vl-file-copy savefilename autosavefilename)
      (setq asv:timetosave nil)
    )
  )
  (if (not asv:timetosave)
    (setq ;; one minute is 0.000694444444445 days
          juliansavetime (* (mwe:getvar "savetime") 0.000694444444445)
          asv:timetosave (+ date (* juliansavetime 0.20))
    )
  )
  (princ)
)




;;; Load the AutoSave Reactor
(vlr-command-Reactor "Command reactor" '((:vlr-commandWillStart . KDUB:AutoSave)))

(princ)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: CMDACTIVE/Reactor Question
« Reply #17 on: February 23, 2010, 05:41:42 PM »


just be prepared to regularly clean out the folder pointed to by (getvar "savefilepath")

:)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: CMDACTIVE/Reactor Question
« Reply #18 on: February 23, 2010, 05:49:14 PM »

Then there is something like this
http://www.theswamp.org/index.php?topic=17552.msg212071#msg212071

which requires the user to DECIDE to save/backup an archive.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Chris

  • Swamp Rat
  • Posts: 548
Re: CMDACTIVE/Reactor Question
« Reply #19 on: February 24, 2010, 09:06:27 AM »

Do you want to keep each backup version ?


I have another program that cleans out the folder on the first of each month, so we have no more than 2 months worth of backups at any point in time. so cleaning it up isnt really a concern.
it sounds like your program is very similar to mine, it checks dates saves the file and creates a backup, however I noticed yours runs on command will start, mine runs on command ended.  Is it better to do one than the other?
Christopher T. Cowgill, P.E.
AEC Collection 2020 (C3D)
Win 10