.NET

Reply
Contributor
Sined99
Posts: 15
Registered: ‎04-26-2013
Message 1 of 6 (359 Views)
Accepted Solution

problme with saveAs(), current document

359 Views, 5 Replies
05-16-2013 11:49 PM

Hello,

 

I have a little problem, I am working with visual studio 2010 and autocad 2013, when I make a new command that save the current work(.dwg), I must use Save.As(....) because the Save() function doesnt work. When I use the SaveAs(..) method, the file is saved correcty in the path(C:\temp, for example),but (here is the problem) the current .dwg that I have in autocad is named "drawing1.dwg",and I will that when I "SaveAs()" a file, the file that shows autocad is the saved file(the new name of the file must appear in the title of the autocad document)... I know its hard to explain...

 

I have attached 3 picture to try to explain it better

 

Thank you very much.

Valued Contributor
amanero
Posts: 73
Registered: ‎12-03-2003
Message 2 of 6 (343 Views)

Re: problme with saveAs(), current document

05-17-2013 02:44 AM in reply to: Sined99

Instead of doing a "SaveAs", you could do a "WBlock":

 

Database newDB = HostApplicationServices.WorkingDatabase.Wblock();

newDB.SaveAs(...);

Luis Alberto Manero, Geograma.com
Valued Contributor
bojko108
Posts: 61
Registered: ‎01-23-2011
Message 3 of 6 (338 Views)

Re: problme with saveAs(), current document

05-17-2013 02:52 AM in reply to: Sined99

"drawing1.dwg" is still the active document, in order to work with newly created "c:/temp/test.dwg" you can open it with:

Application.DocumentManager.Open(newDwg, false);

 

Can you show us part of your code, what's the reason that Document.Save() method does not work?

Employee
artc2
Posts: 205
Registered: ‎06-08-2010
Message 4 of 6 (327 Views)

Re: problme with saveAs(), current document

05-17-2013 05:33 AM in reply to: Sined99

The save method is only for use in RealDWG applications - it will not work in AutoCAD.

 

There are three Database.SaveAs() methods.  If you use this one:

 

Autodesk.AutoCAD.DatabaseServices.Database.SaveAs(string, bool, Autodesk.AutoCAD.DatabaseServices.DwgVersion, Autodesk.AutoCAD.DatabaseServices.SecurityParameters)

 

and pass in true for the bool second argument, then it should change the name of the document in the Acad titlebar.

Contributor
Sined99
Posts: 15
Registered: ‎04-26-2013
Message 5 of 6 (295 Views)

Re: problme with saveAs(), current document

05-19-2013 11:44 PM in reply to: Sined99

Hello,

 

Thanks for the answears!, but it doesnt works... if I try to open the saved file it throws an exception (attached picture). When I try the saveAs method with the 4 parameters the compiler says that is an obsolete method. I am working with autocad 2013 and visual studio 2010.

 

My code:

 

Guardar guardar;[CommandMethod("SaveAsEsquema", CommandFlags.Session)]       

public void SaveActiveDrawing()

        {

            guardar =new Guardar();

            Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(guardar);

        }

      

privatevoid bt_Click(object sender, EventArgs e)

{           

Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;

Database db = acDoc.Database;           

string path = "C:\\Trabajo\\DWG\\TEST.dwg";           

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

db.SaveAs(path,DwgVersion.Current......

}

Contributor
Sined99
Posts: 15
Registered: ‎04-26-2013
Message 6 of 6 (281 Views)

Re: problme with saveAs(), current document

05-20-2013 05:34 AM in reply to: Sined99

Hello,

 

I have solved my problem using this:

 

db.SaveAs(path,true, DwgVersion.Current, null);

 

thank for all the answears.

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.