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.
Solved! Go to Solution.
Solved by artc2. Go to Solution.
Instead of doing a "SaveAs", you could do a "WBlock":
Database newDB = HostApplicationServices.WorkingDatabase.Wblock();
newDB.SaveAs(...);
"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?
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,
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......
}
Can't find what you're looking for? Ask the community or share your knowledge.