Author Topic: Save Drawing  (Read 7163 times)

0 Members and 1 Guest are viewing this topic.

A_LOTA_NOTA

  • Guest
Save Drawing
« on: August 17, 2007, 09:44:00 AM »
Is it possible to call the “SAVEAS” dialogue?

I’ve got a situation where I want to get the drawing name. So I want to test to make sure the drawing has been saved first. If not I would like to “SAVEAS” then get the drawing name.

Thanks

Guest

  • Guest
Re: Save Drawing
« Reply #1 on: August 17, 2007, 09:50:29 AM »
(getvar "DWGTITLED")

If it = 0, the drawing hasn't been saved yet.
It if = 1, the drawing has already been saved.

A_LOTA_NOTA

  • Guest
Re: Save Drawing
« Reply #2 on: August 17, 2007, 09:57:48 AM »
(getvar "DWGTITLED")

If it = 0, the drawing hasn't been saved yet.
It if = 1, the drawing has already been saved.

Thanks Matt but I knew that much. What I'm having a problem with it the "SAVEAS" part. If I just do a "Command SAVEAS" the user is not given a dialog box. I would like the "SAVEAS" dialog box to be displayed!
« Last Edit: August 17, 2007, 10:47:34 AM by A_LOTA_NOTA »

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Save Drawing
« Reply #3 on: August 17, 2007, 10:00:29 AM »
Look at (setvar 'filedia 1)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

A_LOTA_NOTA

  • Guest
Re: Save Drawing
« Reply #4 on: August 17, 2007, 10:04:29 AM »
Look at (setvar 'filedia 1)

It's set to 1!

Guest

  • Guest
Re: Save Drawing
« Reply #5 on: August 17, 2007, 10:11:52 AM »
So what exactly is happening when the user does a SAVEAS?

A_LOTA_NOTA

  • Guest
Re: Save Drawing
« Reply #6 on: August 17, 2007, 10:34:40 AM »
So what exactly is happening when the user does a SAVEAS?

If I click on "File" then "SAVEAS" everything works fine! But if I add (command ".SAVEAS") to my code it doesn't give a dialog box. So I thought I must be coding it wrong.
« Last Edit: August 17, 2007, 10:47:57 AM by A_LOTA_NOTA »

Guest

  • Guest
Re: Save Drawing
« Reply #7 on: August 17, 2007, 10:38:30 AM »
Is filedia set to 0 somewhere in your code prior to the saveas?

A_LOTA_NOTA

  • Guest
Re: Save Drawing
« Reply #8 on: August 17, 2007, 10:44:00 AM »
No, I can have

Code: [Select]
(defun c:TEST ()
  (setvar 'filedia 1)
  (command ".SAVEAS")
  )

& I still get the command line version!

Willie

  • Swamp Rat
  • Posts: 958
  • Going nowhere slowly
Re: Save Drawing
« Reply #9 on: August 17, 2007, 10:47:56 AM »
Try


(defun c:TEST ()
  (initdia)
  (command ".SAVEAS")
  )
Soli Deo Gloria | Qui Audet Adipiscitur
Windows 8  64-bit Enterprise | Civil 3D 2015 and 2016| ArcGIS 10.1
Yogi Berra : "I'd give my right arm to be ambidextrous."

A_LOTA_NOTA

  • Guest
Re: Save Drawing
« Reply #10 on: August 17, 2007, 10:49:15 AM »
Try


(defun c:TEST ()
  (initdia)
  (command ".SAVEAS")
  )

That did it!! Thanks everyone!!!!

Guest

  • Guest
Re: Save Drawing
« Reply #11 on: August 17, 2007, 10:49:24 AM »
No, I can have

Code: [Select]
(defun c:TEST ()
  (setvar 'filedia 1)
  (command ".SAVEAS")
  )

& I still get the command line version!

Part of the problem is with the second line of code...

(setvar 'filedia 1) should be (setvar "filedia" 1)

Notice the quotes. . . . . . . . . . . . .^ ^ ^

A_LOTA_NOTA

  • Guest
Re: Save Drawing
« Reply #12 on: August 17, 2007, 10:58:51 AM »
No, I can have

Code: [Select]
(defun c:TEST ()
  (setvar 'filedia 1)
  (command ".SAVEAS")
  )

& I still get the command line version!

Part of the problem is with the second line of code...

(setvar 'filedia 1) should be (setvar "filedia" 1)

Notice the quotes. . . . . . . . . . . . .^ ^ ^

Try it my way, I think you will get the same results!

Willie fixed my problem.

Guest

  • Guest
Re: Save Drawing
« Reply #13 on: August 17, 2007, 11:02:15 AM »
No, I can have

Code: [Select]
(defun c:TEST ()
  (setvar 'filedia 1)
  (command ".SAVEAS")
  )

& I still get the command line version!

Part of the problem is with the second line of code...

(setvar 'filedia 1) should be (setvar "filedia" 1)

Notice the quotes. . . . . . . . . . . . .^ ^ ^

Try it my way, I think you will get the same results!

Willie fixed my problem.

Huh... no $*#%.  I never knew that nor have I ever seen it done that way (until today).

Cool.

A_LOTA_NOTA

  • Guest
Re: Save Drawing
« Reply #14 on: August 17, 2007, 11:16:12 AM »
No, I can have

Code: [Select]
(defun c:TEST ()
  (setvar 'filedia 1)
  (command ".SAVEAS")
  )

& I still get the command line version!

Part of the problem is with the second line of code...

(setvar 'filedia 1) should be (setvar "filedia" 1)

Notice the quotes. . . . . . . . . . . . .^ ^ ^

Try it my way, I think you will get the same results!

Willie fixed my problem.

Huh... no $*#%.  I never knew that nor have I ever seen it done that way (until today).

Cool.

Only saves one key stroke but I like it better!
« Last Edit: August 17, 2007, 11:19:19 AM by A_LOTA_NOTA »

A_LOTA_NOTA

  • Guest
Re: Save Drawing
« Reply #15 on: August 17, 2007, 07:51:17 PM »
Try


(defun c:TEST ()
  (initdia)
  (command ".SAVEAS")
  )

This worked good for "SAVEAS" but now I have the same problem when closing a drawing. If I type close at the command line I get the dialog asking if I want to save changes. But if I use Close in a lisp it prompts me to save at te command line.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Save Drawing
« Reply #16 on: August 17, 2007, 08:46:09 PM »
the mechanism is the same for the save/saveas dialogs
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

A_LOTA_NOTA

  • Guest
Re: Save Drawing
« Reply #17 on: August 17, 2007, 11:30:24 PM »
the mechanism is the same for the save/saveas dialogs

So may be I need to run some sort of test to see if the drawing needs to be saved before closing it?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Save Drawing
« Reply #18 on: August 17, 2007, 11:33:32 PM »

Have a look at the DBMOD system variable.
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.

A_LOTA_NOTA

  • Guest
Re: Save Drawing
« Reply #19 on: August 17, 2007, 11:36:08 PM »

Have a look at the DBMOD system variable.

Thank you! Looks like that will work!

added: After more thought I shouldn't need to do any testing. If I tell AutoCAD I want to close a drawing it does the testing for me. But I don't get the "Save Changes Yes No Cancel" dialog.
« Last Edit: August 17, 2007, 11:45:11 PM by A_LOTA_NOTA »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Save Drawing
« Reply #20 on: August 17, 2007, 11:45:39 PM »

You should also look at at the DWGTITLED variable
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.

A_LOTA_NOTA

  • Guest
Re: Save Drawing
« Reply #21 on: August 17, 2007, 11:49:52 PM »

You should also look at at the DWGTITLED variable

I have that one in my code & everything works great. But I had to make my own DCL for the "Do you want to save changes". But I shouldn't have to do that! AutoCAD knows the changes have been made & prompts me to save. But it does it at the command line, not with the DCL like it would if I typed "Close" at the command prompt.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Save Drawing
« Reply #22 on: August 17, 2007, 11:52:17 PM »
added: ... But I don't get the "Save Changes Yes No Cancel" dialog.

Have a look at the initdia Help .. some commands do not make use of it.

reading the help now, I note that .SaveAs is not mentioned, so it's usage IS a bonus. ;-)
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.

A_LOTA_NOTA

  • Guest
Re: Save Drawing
« Reply #23 on: August 17, 2007, 11:58:24 PM »
Kerry,

 I just learned about "Initdia" at the beginning of this thread. When I had the same problem with "SAVEAS" as I'm having with "CLOSE". It fixed the saveas problem but doesn't seam to change close.

I have looked in the help file for '06 & '08. Didn't find it in either one.

A_LOTA_NOTA

  • Guest
Re: Save Drawing
« Reply #24 on: August 18, 2007, 12:02:59 AM »
If I use the following code I just get prompted at the command line to save the drawing.

Code: [Select]
(defun c:TEST ()
  (initdia)
  (command ".Close" puase)
  )

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Save Drawing
« Reply #25 on: August 18, 2007, 12:04:21 AM »
I'm interested (from a design perspective) why you  or your users would not be happy with the default command line Prompt.
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.

A_LOTA_NOTA

  • Guest
Re: Save Drawing
« Reply #26 on: August 18, 2007, 12:09:10 AM »
I'm interested (from a design perspective) why you  or your users would not be happy with the default command line Prompt.

It would work fine. But if I type "Close" at the command prompt or click "file" then "exit", AutoCAD gives a dialog asking if I would like to save changes. So in trying to make my program act like a standard AutoCAD command.

Just picky I guess.....

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Save Drawing
« Reply #27 on: August 18, 2007, 12:11:16 AM »
If I use the following code I just get prompted at the command line to save the drawing.

Code: [Select]
(defun c:TEST ()
  (initdia)
  (command ".Close" puase)
  )

I haven't tested, I'll leave that to you, but I don't believe you need the 'pause ...
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.

A_LOTA_NOTA

  • Guest
Re: Save Drawing
« Reply #28 on: August 18, 2007, 12:16:19 AM »
If I use the following code I just get prompted at the command line to save the drawing.

Code: [Select]
(defun c:TEST ()
  (initdia)
  (command ".Close" puase)
  )

I haven't tested, I'll leave that to you, but I don't believe you need the 'pause ...

No, the pause is not need. I was posting the code more for the fact that I tried INITDIA and it doesn't change anything. And so someone could see a part of what I was trying to do & could may be point out why I don't get the dialog box like I do if entering "close" at the comand prompt.

A_LOTA_NOTA

  • Guest
Re: Save Drawing
« Reply #29 on: August 18, 2007, 09:57:56 AM »
Got it!!
Code: [Select]
(defun c:TEST1 ()
  (vla-sendcommand
    (vla-get-activedocument (vlax-get-acad-object))
    ".close ")
  )