.NET

Reply
Active Contributor
Luigi71
Posts: 27
Registered: ‎08-30-2011
Message 1 of 3 (184 Views)

Title bar not updating

184 Views, 2 Replies
11-16-2012 03:59 AM

First of all I wish to greet all.

Then, I wrote a loop to save automatically a list of documents with the SaveAs method (Database.SaveAs).

The code is the following:

 

doc.Database.SaveAs(path, True, DwgVersion.Current, doc.Database.SecurityParameters).

 

While the documents are correctly saved with the correct new name (e.g. Map1.dwg, Map2.dwg, etc.)  in the correct location, the doc.Name properties are not updated, the title bar of autocad also. They still remains Drawing1.dwgDrawing2.dwg, etc.

 

Anyone have some suggestion?

 

Thanks

ADN Support Specialist
Balaji_Ram
Posts: 733
Registered: ‎03-21-2011
Message 2 of 3 (153 Views)

Re: Title bar not updating

11-21-2012 08:55 AM in reply to: Luigi71

Greetings to you too.

 

Saving the database with a different file name does not update the document.

To do that, you can send the "SaveAs" command as in this code snippet :

 

[CommandMethod("Test", CommandFlags.Session)]
public void TestMethod()
{
    object filediaVariable = Application.GetSystemVariable("FILEDIA");
    Application.SetSystemVariable("FILEDIA", 0);

    DocumentCollection acDocMgr = Application.DocumentManager;
    foreach (Document doc in acDocMgr)
    {
        dynamic acadDoc = doc.GetAcadDocument();
        String newFileName = doc.Database.Filename.Replace(".dwg", "_New.dwg");
        acadDoc.SendCommand(String.Format("saveas\n\n{0}\n", newFileName));
    }
    Application.SetSystemVariable("FILEDIA", filediaVariable);
}

I have used the dynamic keyword available in .Net framework 4.0. If you are using AutoCAD 2011 which targets the 3.5 framework, you can replace it with AcadDocument and add references to the AutoCAD COM interop assemblies.

 

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Active Contributor
Luigi71
Posts: 27
Registered: ‎08-30-2011
Message 3 of 3 (131 Views)

Re: Title bar not updating

11-22-2012 07:39 AM in reply to: Luigi71

Thanks for the tip.

 

Seems to works fine

 

Very Helpful

 

Thankyou

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!