Results 1 to 6 of 6

Thread: Save DWG file to local backup drive

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Member
    Join Date
    2003-06
    Posts
    38
    Login to Give a bone
    0

    Default Save DWG file to local backup drive

    Hi all, We have had a few issues now w/ our server maintenance and backup procedures which as the backup was restored we lost the previous days work. I do save regularly and also have my Autosave set at 10 min to my local drive, so I've lost minimal data.. But I'd like to have a Lisp routine or add to my save Macro to save my current file to my local backup drive after I save to the server. I' have very minimal AutoLisp skills, so please don't laugh too hard on this
    (DEFUN C:S ()
    (COMMAND "SAVE" "" "SAVE" "D:\temp"getvar" "DWGNAME"))
    Any thoughts on how to make this work?

    Appreciate your help in advance, Mike

    Below results:

    Command: (LOAD "C:/Lisp/keys.lsp")

    Command: S
    SAVE Save drawing as <N:\265-05\Drawings\Street\07-Signal Plan.dwg>:
    Command: SAVE Save drawing as <N:\265-05\Drawings\Street\07-Signal Plan.dwg>: D: emp"getvar
    "D: emp"getvar": Invalid file name.

    Command: DWGNAME
    DWGNAME = "07-Signal Plan.dwg" (read only)

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,096
    Login to Give a bone
    0

    Default Re: Save DWG file to local backup drive

    As you are also attempting to work with folder paths, you will need to "escape" each of the paths backslashes "". To do that, add a backslash before (or after) at each backslash of the path name. The path you are specifying will also need an additional set of backslashes at the end to make it a folder name.
    Code:
    "D:\\temp\\"
    To get the current drawing name, you will need to use the GETVAR function.
    (getvar 'dwgname)
    The string you are attempting to make needs to be done using the STRCAT function.
    Code:
    (strcat "D:\\temp\\" (getvar 'DWGNAME))
    After that, you can then supply that to your defun,
    Code:
    (defun c:s ()
      (command "save" "" "save" (strcat "D:\\temp\\" (getvar 'DWGNAME)))
    )
    I believe this contains no errors, but I also haven't tested it.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    Member
    Join Date
    2003-06
    Posts
    38
    Login to Give a bone
    0

    Default Re: Save DWG file to local backup drive

    I appreciate the help, it worked like a champ! w/ a SSD hard drive this is pretty fast. I'm not certain that I would recommend this as a normal practice.. though HD space is cheep vs losing data.

    Command: (LOAD "C:/Lisp/keys.lsp")

    Command: S save Save drawing as <N:\108-34.4\Drawings\Plat\Plat_Base.dwg>:
    Command: save Save drawing as <N:\108-34.4\Drawings\Plat\Plat_Base.dwg>: D:\temp\Plat_Base.dwg

  4. #4
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    555
    Login to Give a bone
    0

    Default Re: Save DWG file to local backup drive

    I would reverse the order save to ssd then save to network so last version points to server.

  5. #5
    Member tuomo.jarvinen's Avatar
    Join Date
    2015-09
    Location
    Jyväskylä, Finland
    Posts
    49
    Login to Give a bone
    0

    Default Re: Save DWG file to local backup drive

    I have been using this for a while. It creates a sub-folder "old" and copies there the dwg prior to actual saving, with time- and username - tags.

    Code:
    (defun c:bup (/ curfilename CopySaveLocation CurFileName newlen SaveTime mainfilepathname backupfilename savetime userluprec mainfilepathcopyname curfilecopyname)
    (setq userluprec (getvar "luprec"))
    (setvar "luprec" 6)
    (vl-load-com)
    (vl-mkdir (strcat (getvar "dwgprefix") "old"))
    (setq CopySaveLocation (strcat (getvar "dwgprefix") "old"))
    (setq CurFileName (getvar "dwgname"))
    (setq newlen (- (strlen CurFileName) 4))
    (setq CurFileName (substr CurFileName 1 newlen))
    (setq UserName (getvar "loginname"))
    
    (setq SaveTime (rtos (getvar "cdate")))
    (setq SaveTime (strcat (substr SaveTime 1 4) "-" (substr SaveTime 5 2) "-" (substr SaveTime 7 2) "-" (substr SaveTime 10 6)))
    
    (setq CopyFileName (strcat CurFileName "_backup_" SaveTime "_" UserName))
    
    (setvar "filedia" 0)
    
    (setq CurPathCurFileName (strcat (getvar "dwgprefix") (getvar "dwgname")))
    (setq CopySaveLocationCopyFileName (strcat CopySaveLocation "\" CopyFileName ".dwg" ))
    
    (vl-file-copy CurPathCurFileName CopySaveLocationCopyFileName)
    
    (command "qsave")
    (setvar "filedia" 1)
    (setvar "luprec" userluprec)
    (princ)
    )

  6. #6
    100 Club
    Join Date
    2004-10
    Location
    Scotland
    Posts
    102
    Login to Give a bone
    0

    Default Re: Save DWG file to local backup drive

    Jim Dee provided an archive DWG archiving utility that I've tweaked for my own use which has been helpful.
    Available from https://cadtips.cadalyst.com/saving-...hiving-utility

Similar Threads

  1. 2014: Revit reporting Central File is not available, no one else is in file, can't save, won't create local file
    By patricks in forum Revit - Worksharing/Worksets/Revit Server
    Replies: 3
    Last Post: 2013-10-03, 10:31 PM
  2. Backup files should go into a "Backup" folder
    By revit.wishlist1942 in forum Revit Architecture - Wish List
    Replies: 7
    Last Post: 2012-03-09, 06:06 PM
  3. Local Files: program to delete local file and create a new local file
    By mailshanegross in forum Revit - Worksharing/Worksets/Revit Server
    Replies: 4
    Last Post: 2009-06-03, 02:29 AM
  4. Recover backup of Revit Central or Local File
    By pbyrne in forum Revit - Worksharing/Worksets/Revit Server
    Replies: 2
    Last Post: 2006-10-21, 04:39 AM
  5. Recover backup of Revit Central or Local File
    By pbyrne in forum Revit Architecture - Tips & Tricks
    Replies: 1
    Last Post: 2006-10-21, 03:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •