Author Topic: Incremental Save As  (Read 21800 times)

0 Members and 1 Guest are viewing this topic.

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Incremental Save As
« on: July 12, 2007, 03:27:14 PM »
What I have been attempting to do with little success is to create a Toolbar button to do the following:

Save the current drawing; then perform a Save As to the current drawing name +BAK.dwg.

The reason for this curious function is that despite the Recovery Manager, or perhaps because of it Civil 3D has the annoying habit of reporting that the recovery file is INVALID.
As a workaround to this annoyance I have adopted the habit of performing a save as to a DWGNAMEBAK.dwg, and then as save as back the original filename. In this manner I can depend on MY saved as file to be complete when C3D, and Recovery manager decides to munch my design file.

i would like to add this to a button to make it easier, and thus more likely to be used by other users; so that they too will stop losing work to this feature.

« Last Edit: July 12, 2007, 03:29:28 PM by mjfarrell »
Be your Best


Michael Farrell
http://primeservicesglobal.com/

Arizona

  • Guest
Re: Incremental Save As
« Reply #1 on: July 12, 2007, 03:30:23 PM »
Could an alternate method be to wblock all to that filename?

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Incremental Save As
« Reply #2 on: July 12, 2007, 03:35:48 PM »
anything will be acceptable as long as A) it can be on a button menu and B) it results in kepping both files in same folder with a slightly different name, i.e.  DWGNAMEBAK, or DWGNAME01, etc.
Be your Best


Michael Farrell
http://primeservicesglobal.com/

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Incremental Save As
« Reply #3 on: July 12, 2007, 03:39:19 PM »
You can do it this way.
Code: [Select]
(progn
 (command "_.qsave")
 (command "_.save" (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) "-Bak.dwg"))
)
This will save the current file, both to the name you want, and a back up one, and will leave you in the real drawing.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Arizona

  • Guest
Re: Incremental Save As
« Reply #4 on: July 12, 2007, 03:44:58 PM »
Nice one! ^^ :-)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Incremental Save As
« Reply #5 on: July 12, 2007, 03:46:50 PM »
Nice one! ^^ :-)
Thanks!  Learned that trick (using the save command that way) over on the Adesk Ng awhile back, and never have forgotten it.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Dinosaur

  • Guest
Re: Incremental Save As
« Reply #6 on: July 12, 2007, 03:47:46 PM »
I thank you Tim . . . I am thinking about naming thebutton SaveMyA**
« Last Edit: July 12, 2007, 03:48:55 PM by DinØsaur »

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Incremental Save As
« Reply #7 on: July 12, 2007, 03:52:32 PM »
Perfectly marvelous....except upon the second use the user is promted y/n to overwrite the DWGNAMEBAK file. Can this be set to Yes, to work without the user being prompted?
Be your Best


Michael Farrell
http://primeservicesglobal.com/

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Incremental Save As
« Reply #8 on: July 12, 2007, 03:55:28 PM »
Perfectly marvelous....except upon the second use the user is promted y/n to overwrite the DWGNAMEBAK file. Can this be set to Yes, to work without the user being prompted?
I just saw that, so I think we should make it it's own function.
Code: [Select]
(defun c:SaveMyA** (/ NewPath)

(setq NewPath (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) "-Bak.dwg"))
(command "_.qsave")
(if (findfile NewPath)
 (command "_.save" NewPath "_yes")
 (command "_.save" NewPath)
)
(princ)
)

I thank you Tim . . . I am thinking about naming thebutton SaveMyA**
You're very much welcomed, and thanks for a name for the function. :-D
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: Incremental Save As
« Reply #9 on: July 12, 2007, 03:57:00 PM »
if I remember use (setvar "expert" 2) - but wait for master Tim....

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Incremental Save As
« Reply #10 on: July 12, 2007, 03:58:36 PM »
ok, the official name is SaveMyA**,

only now that code doesn't work in the button....what did we break?
Be your Best


Michael Farrell
http://primeservicesglobal.com/

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Incremental Save As
« Reply #11 on: July 12, 2007, 03:58:53 PM »
if I remember use (setvar "expert" 2) - but wait for master Tim....
Looks around..... No master Tim I see...  :-)

I don't mess with "expert" variable, but from the help you are correct master Luis.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Incremental Save As
« Reply #12 on: July 12, 2007, 04:00:16 PM »
ok, the official name is SaveMyA**,

only now that code doesn't work in the button....what did we break?
If you just want it in a button, then no need to name it, but use this code instead.
Code: [Select]
(progn
 (setq NewPath (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) "-Bak.dwg"))
 (command "_.qsave")
 (if (findfile NewPath)
  (command "_.save" NewPath "_yes")
  (command "_.save" NewPath)
 )
 (setq NewPath nil)
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

mjfarrell

  • Seagull
  • Posts: 14444
  • Every Student their own Lesson
Re: Incremental Save As
« Reply #13 on: July 12, 2007, 04:05:50 PM »
ok, i think we broke something in there...??

the first piece of code, when pasted to the button worked on the first click...
 the revised code does not function on the first click and appears to stick in a loop:

from ACAD Text Window:

Command: (progn
(_>  (setq NewPath (strcat (getvar "dwgprefix") (vl-filename-base (getvar
"dwgname")) "-Bak.dwg"))
(_>  (command "_.qsave")
(_>  (if (findfile NewPath)
((_>   (command "_.save" NewPath "_yes")
((_>   (command "_.save" NewPath)
((_>  )
(_>  (setq NewPath nil)
(_> )
_.qsave
Command: _.save Save drawing as <C:\Civil 3D Projects\UEP SW 6 and 7\Sample
Surface Model.dwg>: C:\Civil 3D Projects\UEP SW 6 and 7\Sample Surface
Model-Bak.dwg A drawing with this name already exists.
Do you want to replace it? <N> _yes
Command: nil
Be your Best


Michael Farrell
http://primeservicesglobal.com/

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Incremental Save As
« Reply #14 on: July 12, 2007, 04:08:22 PM »
_.qsave
Command: _.save Save drawing as <C:\Civil 3D Projects\UEP SW 6 and 7\Sample
Surface Model.dwg>: C:\Civil 3D Projects\UEP SW 6 and 7\Sample Surface
Model-Bak.dwg A drawing with this name already exists.
Do you want to replace it? <N> _yes
Command: nil
Looks like it worked to me?  Did it not save it?

nil is returned because the last line of the code sets the path to nil, so that it can't be used in another lisp you use.  This is a precaution.

If you don't like the nil, then place (princ) after the line (setq NewPath nil).
« Last Edit: July 12, 2007, 04:09:24 PM by T.Willey »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.