Jump to content

Recommended Posts

Posted

Hi All,

 

I was wondering if there was a way to save a copy of my drawing into two different locations when i hit a button..ie flash drive hooked to my computer and my sever at the same time?

 

Thanks,

Brian

Posted

I recommend saving the active drawing, and then copying the saved file to the other location using the vl-file-copy function.

 

Here is an example, change the [highlight]highlighted[/highlight] path to suit:

 

([color=BLUE]defun[/color] c:mysave ( [color=BLUE]/[/color] dwg pth tmp )
   ([color=BLUE]setq[/color] pth [highlight][color=MAROON]"C:"[/color][/highlight] [color=GREEN];; Second save location[/color]
         dwg ([color=BLUE]strcat[/color] ([color=BLUE]vl-string-right-trim[/color] [color=MAROON]"\\"[/color] ([color=BLUE]vl-string-translate[/color] [color=MAROON]"/"[/color] [color=MAROON]"\\"[/color] pth)) [color=MAROON]"\\"[/color] ([color=BLUE]getvar[/color] 'dwgname))
   )
   ([color=BLUE]cond[/color]
       (   ([color=BLUE]zerop[/color] ([color=BLUE]getvar[/color] 'dwgtitled))
           ([color=BLUE]princ[/color] [color=MAROON]"\nCurrent drawing is unsaved."[/color])
       )
       (   ([color=BLUE]and[/color] ([color=BLUE]setq[/color] tmp ([color=BLUE]findfile[/color] dwg))
               ([color=BLUE]progn[/color]
                   ([color=BLUE]initget[/color] [color=MAROON]"Yes No"[/color])
                   ([color=BLUE]=[/color] [color=MAROON]"No"[/color] ([color=BLUE]getkword[/color] [color=MAROON]"\nFile already exists in second location, overwrite? [Yes/No] <Yes>: "[/color]))
               )
           )
       )
       (   [color=BLUE]t[/color]
           ([color=BLUE]command[/color] [color=MAROON]"_.qsave"[/color])
           ([color=BLUE]if[/color] tmp ([color=BLUE]vl-file-delete[/color] tmp))
           ([color=BLUE]vl-file-copy[/color] ([color=BLUE]strcat[/color] ([color=BLUE]getvar[/color] 'dwgprefix) ([color=BLUE]getvar[/color] 'dwgname)) dwg)
       )
   )
   ([color=BLUE]princ[/color])
)
([color=BLUE]vl-load-com[/color]) ([color=BLUE]princ[/color])

Posted

Lee,

 

if you haven't been told today that you are awesome..YOU ARE AWESOME!!!!!

 

Thanks for the help,:notworthy:

Brian:D

  • 1 year later...
Posted

Hey Lee and Brian,

 

Sorry to dust off this old post, but I have come to the same need and was lucky enough to find this! Unfortunately, I seem to be running into an issue of the LISP completing to the directory I provided. If I just use the root directory it works perfect, but as soon as I add any subfolders, there is no output. Is there a special way to handle file paths in LISP so that they work?

 

I have even tried using the DOS naming convention which didn't work either.

 

(defun c:mysave ( / dwg pth tmp )
   (setq pth [color="blue"]"D:\Users\Eric\Advanced Architectural Stone\Backup[/color]" ;; Second save location
         dwg (strcat (vl-string-right-trim "\\" (vl-string-translate "/" "\\" pth)) "\\" (getvar 'dwgname))
   )
   (cond
       (   (zerop (getvar 'dwgtitled))
           (princ "\nCurrent drawing is unsaved.")
       )
       (   (and (setq tmp (findfile dwg))
               (progn
                   (initget "Yes No")
                   (= "No" (getkword "\nFile already exists in second location, overwrite? [Yes/No] <Yes>: "))
               )
           )
       )
       (   t
           (command "_.qsave")
           (if tmp (vl-file-delete tmp))
           (vl-file-copy (strcat (getvar 'dwgprefix) (getvar 'dwgname)) dwg)
       )
   )
   (princ)
)
(vl-load-com) (princ)

Posted

It may be the spaces in the directory name try

 

D:\\Users\\Eric\\Advanced Architectural Stone\\Backup

 

As a simple test rename Advanced_Architectural_Stone and try again

Posted

Hi eric,

 

You should use either single forward slashes or double-backslashes as path delimiters, e.g.:

"D:[highlight]/[/highlight]Users[highlight]/[/highlight]Eric[highlight]/[/highlight]Advanced Architectural Stone[highlight]/[/highlight]Backup"

Or:

"D:[highlight]\\[/highlight]Users[highlight]\\[/highlight]Eric[highlight]\\[/highlight]Advanced Architectural Stone[highlight]\\[/highlight]Backup"

The use of single backslashes will cause unexpected results for this reason.

Posted

As always, fantastic Lee!!!!

 

On last question regarding the file path: Is that path able to be a network path instead of local? Like if I wanted to save a backup to another computer will a LISP be able to use a UNC?"

 

Also, Lee, I have been meaning to ask you something. I'll send you a pm.

 

Thanks Again!!!!

Posted

The network path is no different to local paths use the correct slashes.

 

As I commented above before Lee I use the underscore and minus des_des des-des for directory names then the slashes become easier to remember as spaces are not there.

Posted
As always, fantastic Lee!!!!

 

Excellent - you're welcome eric :)

 

On last question regarding the file path: Is that path able to be a network path instead of local? Like if I wanted to save a backup to another computer will a LISP be able to use a UNC?"

 

Certainly, just be careful to double-up the backslashes (such paths usually result in leaning-toothpick syndrome :lol: ).

 

I describe an easy way to determine how the path should look when used in AutoLISP in the thread that I linked to in my last post - you can use the following simple program to determine the correct path to use:

(defun c:literal ( ) (getstring t "\nEnter string: "))

For example:

Command: literal
Enter string: \\myserver\myfolder\mybackup
[highlight]"\\\\myserver\\myfolder\\mybackup"[/highlight]

Posted

That is a cool little LISP! Just for curiosity's sake, would it be possible to take it a step further? Compile all of the steps into one LISP so that this can just become a special QSAVE. Where, when invoked, the opened drawing would be saved back to it's inital location as well as a secondary location. The second version of this LISP...and I bet I am pushing this...would then save the secondary drawing back to the original location?

 

Maybe it would help if I gave the purpose behind this request. I currently work from home, and I am teaching my wife how to draw because she has always wanted to learn and she wants to help spread the workload. The way we are managing the files currently is that my computer acts as the central location and she saves a copy to her machine just in case there is any kind of disconnect. I am trying to figure out how to simplify her process.

Posted

just change the macro name from ^C^C_qsave to the name of the Lisp on her computer, under customize in AutoCAD.

Posted
Maybe it would help if I gave the purpose behind this request. I currently work from home, and I am teaching my wife how to draw because she has always wanted to learn and she wants to help spread the workload. The way we are managing the files currently is that my computer acts as the central location and she saves a copy to her machine just in case there is any kind of disconnect. I am trying to figure out how to simplify her process.

 

Why not use Dropbox, or a similar free cloud-based service?

  • 2 years later...
Posted

Hello

 

 

I would like to create something like central file. For example. I would like to create XX file-central file on company server. I will copy this file into my computer-XY. My friend will copy this file to his computer-XZ. I'm working on power and he is working on lighting. I would like to save my work on my computer and auto save on central file. And my friend would like to save his work on his computer and also auto save on central file. Is it possible without "removing" my or his work? Is it possible to auto save on "central" file without removing previous job but only add new stuff?

  • 1 year later...
Posted

Lee,

 

I came across this thread from a few years ago, hoping you can help with a similar issue (if you see this). I need to do the same thing, save a copy of drawing files by just invoking the normal QSAVE or clicking save. My thought is replace the QSAVE command with a custom command? My only issue is we are working just now upgrading to 2018 and I want to maintain a parallel copy of our drawing files as 2013 versions. I am thinking it will be a huge time saver if at the end of a project we have a running set of 2013 files to send to our clients. We are working on large 3D files and the batch converter seems to take some time to even load a few files. 

 

Is this possible or even make sense to do? Is there an alternative?

 

Thanks!

Dustin

 

 

 

 

 

 

 

Posted

you could use a double save-as , where the first would save as 2013 in the parallel folder and the second saveas 2018 back in the original folder. Other way could be to batch convert them using the autocad core console. This can also run as a separate / multiple thread but you probably need some serious amount of Ram. I would have prefered using odbx but its saveas function only can save a drawing in its native format so when called from AutoCad 2013 it can only saveas 2013. Maybe things have changed since 2018 , haven't tried that yet but I suspect it can only saveas 2018.

 

And of course you could just use a simple script and when you go home leave your pc on and let it do the saveas stuf while you do the hard work : eating & sleeping (no I don't wanna know about the rest)

Posted

Thanks RLX, 

 

I am hoping I can find a way to make this a seamless operation with a routine save so our users do not even need to think about it. By simply saving they will be creating a 2018 and 2013 version simultaneously.

 

Its a pipe dream I know... :) 

Posted

routine could be fairly simple. You can redefine the qsave command in your acad.lsp. Only thing to think about is this parallel folder. Is this one fixed folder or will every project have its own 'archive' folder. I have a qs.lsp (c:qs) that is loaded in the startup and all it does is zoom extents , purge & .qsave. My qsave button in the autocad menu still uses the original qsave command.

🛌 😴 💤

Posted
4 hours ago, rlx said:

You can redefine the qsave command in your acad.lsp.

 

Just make sure you have bulletproof error checking. If a user runs QSAVE, he/she expects the drawing to get saved. If a redefined QSAVE fails, for any reason, and doesn't notify the user, well.... you know.  😫

Posted (edited)

I use c:qs , assigned a separate button to it so the standard AutoCAD qsave button / command still works and even if something goes wrong .qsave still uses the built in function. The point is the point in front of qsave if you get the point.

Another option would be to save the drawings in the same folder but append _R13 to the filename-base. Where I work we have an extended folder structure like //serverpath/projectname/area/dwgtype/ where dwgtype can be E for electrical drawings , LD for loops etc. If you use something similar your parallel folder structure should also reflect this unless your happy with one big fat archive folder.

 

and of course you also have the dwgconvert command

 

http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-F7AE3A68-F155-49AD-8721-A7789C0E9540

 

or even use dxf :

 


Command: FILEDIA
Enter new value for FILEDIA <1>: 0

Command: SAVEAS

Current file format: AutoCAD 2010(LT 2010) Drawing
Enter file format [R14(LT98&LT97)/2000(LT2000)/2004(LT2004)/2007(LT2007)/2010(LT2010)/2013(LT2013)/Standards/DXF/Template] <R2010>: dxf

Current DXF settings: Precision= 16 Format= ASCII Preview= No Version= 2013

Enter decimal places of accuracy (0 to 16) or [Binary/select Objects/Preview/Version] <16>: v

Enter version [R12(LT2)/2000(LT2000)/2004(LT2004)/2007(LT2007)/2010(LT2010)/2013(LT2013)] <2013>:

Enter decimal places of accuracy (0 to 16) or [Binary/select Objects/Preview/Version] <16>:
Save drawing as <P:\mm16269_Chlorine\1400\E\14E008021SI130.dxf>:

Edited by rlx

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...