Author Topic: Incremental Save As  (Read 21789 times)

0 Members and 1 Guest are viewing this topic.

justin

  • Guest
Re: Incremental Save As
« Reply #45 on: December 19, 2008, 04:16:36 PM »
Can someone offer a suggestion to change to this code such that the save of the current drawing happens after the save to -bak.dwg? 
We have an auto generated path name attached to our title block and the current code changes the path to -bak.dwg unless another qsave is performed after the current code.  We modified this code to add an additional qsave at the end of the current code, but our modified process involves 3 separate save commands and is quite slow.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Incremental Save As
« Reply #46 on: December 20, 2008, 12:36:12 PM »
suggestion....(tested on 2009 only)

Code: [Select]
(DEFUN c:nsave (/ dname dpref bdir incr)
  (setvar "CMDECHO" 0)
  (setq dname (vl-filename-base (getvar "DWGNAME")))
  (setq dpref (getvar "DWGPREFIX"))
  (setq bdir (strcat dpref "DWGBACKUP\\"))

  (setq incr (rtos (getvar "CDATE") 2 6))

  (if (not (vl-file-directory-p bdir))
    (vl-mkdir bdir)
  )
 
  (if (findfile (strcat bdir dname "-" incr "-Bak.dwg"))
    (vl-cmdf "._save"
     (strcat bdir dname "-" incr "-Bak.dwg")
     "_Y"
    )
    (vl-cmdf "._save" (strcat bdir dname "-" incr "-Bak.dwg"))
  )

(if (findfile (strcat dpref dname ".dwg"))
    (vl-cmdf "._Qsave")
    (vl-cmdf "._save" (strcat dpref dname ".dwg"))
  )
  (princ "\save and backup done !")
  (princ)
)
« Last Edit: December 20, 2008, 01:13:10 PM by Andrea »
Keep smile...

uncoolperson

  • Guest
Re: Incremental Save As
« Reply #47 on: December 20, 2008, 01:19:51 PM »
this is what I've got going on for the drafters i work with
http://www.theswamp.org/index.php?topic=8499.0

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Incremental Save As
« Reply #48 on: December 20, 2008, 01:39:06 PM »
This is what I put in my MNL file so a copy is made via reactor whenever a save ends:

Code: [Select]
(vl-load-com)
(if (not *rjp-CommandReactors*)
  (setq *rjp-CommandReactors*
(vlr-command-reactor
   nil
   '((:vlr-commandEnded . EndCMD))
)
  )
)

(defun EndCMD (calling-reactor EndCMDInfo /)
  (if (wcmatch (strcase (nth 0 EndCMDInfo) T) "*save*")
    (rjp-backupdwg)
  )
)

;;makes a copy a DWG after a save to "C:/AutoCAD-BAK/"...keeps 1/2 hour history
(defun rjp-backupdwg (/ bkupdir date time hour minute dwgpath fullpath dwgdir)
  (if (= (getvar 'dwgtitled) 1)
    (progn (setq bkupdir  "C:/AutoCAD-BAK/";;put the path you want here
date   (rtos (fix (getvar 'cdate)) 2 0)
date   (strcat (substr date 5 2) "." (substr date 7 2) "." (substr date 1 4) "/")
time   (rtos (rem (getvar 'cdate) 1) 2 6)
hour   (substr time 3 2)
minute   (substr time 5 2)
hour   (if (>= (atoi minute) 30)
    (strcat hour "-30/")
    (strcat hour "/")
  )
dwgpath  (strcat (vl-string-right-trim
    "."
    (substr (vl-string-translate "\\\"" "." (getvar 'dwgprefix)) 4)
  )
  "/"
  )
fullpath (strcat bkupdir date hour dwgpath (getvar 'dwgname))
dwgdir   (strcat (getvar 'dwgprefix) (getvar 'dwgname))
   )
   (vl-mkdir bkupdir)
   (vl-mkdir (strcat bkupdir date))
   (vl-mkdir (strcat bkupdir date hour))
   (vl-mkdir (strcat bkupdir date hour dwgpath))
   (if (findfile fullpath)
     (vl-file-delete fullpath)
   )
   (vl-file-copy dwgdir fullpath)
    )
  )
  (princ)
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

justin

  • Guest
Re: Incremental Save As
« Reply #49 on: December 22, 2008, 04:50:19 PM »
We seemed to have resolved our problem using the following code.

Code: [Select]
^C^C(progn
 (setq NewPath (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) "-Bak.dwg"))
  (if (findfile NewPath)
  (command "_.save" NewPath "_yes")
  (command "_.save" NewPath)
 )
 (setq NewPath nil)
(command "_.qsave")
)

Thanks for your input.

<edit CAB: added code tags>
« Last Edit: December 23, 2008, 06:45:36 AM by CAB »

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Incremental Save As
« Reply #50 on: December 23, 2008, 10:23:52 AM »
We seemed to have resolved our problem using the following code.

Code: [Select]
^C^C(progn
 (setq NewPath (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) "-Bak.dwg"))
  (if (findfile NewPath)
  (command "_.save" NewPath "_yes")
  (command "_.save" NewPath)
 )
 (setq NewPath nil)
(command "_.qsave")
)

Thanks for your input.

<edit CAB: added code tags>

Good.. ;-)
but...where is the incremental ?
Keep smile...