.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

problme with saveAs(), current document

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Sined99
1415 Views, 5 Replies

problme with saveAs(), current document

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.

Tags (2)
5 REPLIES 5
Message 2 of 6
amanero
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
Message 3 of 6
bojko108
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?

Message 4 of 6
artc2
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.

Message 5 of 6
Sined99
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......

}

Message 6 of 6
Sined99
in reply to: Sined99

Hello,

 

I have solved my problem using this:

 

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

 

thank for all the answears.

Tags (2)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost