HowTo Suppress a Save Dialog Box.

HowTo Suppress a Save Dialog Box.

rberghLJ4SA
Enthusiast Enthusiast
693 Views
11 Replies
Message 1 of 12

HowTo Suppress a Save Dialog Box.

rberghLJ4SA
Enthusiast
Enthusiast

Hi

 

We running an AutoCAD Extension. We aslo set the system variable SDI to 1 (Single Document Interface).

 

When I use 

Application.DocumentManager.Open

 A save dialog pops up, I need to suppress this dialog. I've tried CloseAndSave but because we're running SDI a document must be open. So basically when I open a doc the active doc will be closed I just don't want the active doc saved.

0 Likes
694 Views
11 Replies
Replies (11)
Message 2 of 12

murugamaha
Contributor
Contributor

Did you tried this, 

   For intI = 0 To Acadapp.Documents.Count - 1 
       Acadapp.Documents.Item(intI).Close(SaveChanges:=False)
       Next

 

0 Likes
Message 3 of 12

rberghLJ4SA
Enthusiast
Enthusiast

Doesn't work we're in Single Document Interface Mode ... Cannot close the document.

 

https://www.autodesk.com/support/technical/article/caas/sfdcarticles/sfdcarticles/Multiple-Design-En...

0 Likes
Message 4 of 12

murugamaha
Contributor
Contributor
Did you try Cmddia variable to 0.
0 Likes
Message 5 of 12

rberghLJ4SA
Enthusiast
Enthusiast

Thanks for your suggestion, unfortunately that did not work.

0 Likes
Message 6 of 12

murugamaha
Contributor
Contributor
if it is ok and you do not feel irritated, can you send a video, so that i can understand the sequence
0 Likes
Message 7 of 12

ActivistInvestor
Mentor
Mentor

I would suggest that you try doing a SaveAs to a file in the temp folder and always overwrite any existing file so that the drawing is not in an unsaved state and the save dialog won't appear. I honestly don't think that there's any other way around that problem. 

0 Likes
Message 8 of 12

rberghLJ4SA
Enthusiast
Enthusiast

Sorry if I can across as irretated, I wasn't. I happy to try anything at this point

Message 9 of 12

rberghLJ4SA
Enthusiast
Enthusiast

I am going try that now.

0 Likes
Message 10 of 12

rberghLJ4SA
Enthusiast
Enthusiast

 

 

 

object obj = Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("DWGTITLED");

        // Check to see if the drawing has been named
        if (System.Convert.ToInt16(obj) == 0)
        {
            if (File.Exists(Path.Combine(FileHandler.AppDataInstancePath(), "WorkingDoc.dwg")))
            {
                Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.SaveAs(Path.Combine(Environment.ExpandEnvironmentVariables("%temp%"),"temp.dwg"),true,DwgVersion.Current,null);
                //Still showing save dialog on Open...
                Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(Path.Combine(FileHandler.AppDataInstancePath(), "WorkingDoc.dwg"));
            }

            Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            string strDWGName = acDoc.Name;
            acDoc.Database.SaveAs(Path.Combine(FileHandler.AppDataInstancePath(), "WorkingDoc.dwg"), true, DwgVersion.Current, null);

        }

 

 

 

This is what I've tried, I still get a Save dialog on opening of the WorkingDoc.dwg. Even after saving the default drawing to a temp folder.

 

Btw this is running in Application context during initialization of AutoCAD.

0 Likes
Message 11 of 12

murugamaha
Contributor
Contributor

Can you try this sequence and tell.

  'EndAcadTasks()
  Acadapp = CreateObject("AutoCAD.Application")
  Acadapp.Visible = True
  Acadapp.WindowState = AcWindowState.acMax
  Acaddoc = Acadapp.ActiveDocument
  Acaddoc.SetVariable("SDI", 1)
  Acadapp.Documents.Open("e:\testcad.dwg")

'''' code for endAcadTasks if required 
Public Sub EndAcadTasks()
     Try
         Dim processes As Process() = Process.GetProcessesByName("acad")
         For Each proc As Process In processes
             proc.Kill()
         Next
     Catch ex As Exception
         MsgBox("Error ending acad.exe tasks: " & ex.Message)
     End Try
 End Sub
0 Likes
Message 12 of 12

ActivistInvestor
Mentor
Mentor

I would try using the COM AcadDocument.SaveAs() method. 

0 Likes