.NET

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

problme with saveAs(), current document

386 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.

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.

Hello,

 

I have solved my problem using this:

 

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

 

thank for all the answears.

Valued Contributor
amanero
Posts: 75
Registered: ‎12-03-2003
Message 2 of 6 (370 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 (365 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: 226
Registered: ‎06-08-2010
Message 4 of 6 (354 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 (322 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 (308 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.

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!