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

Error when using AcDbDatabase.SaveAs() method

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
518 Views, 4 Replies

Error when using AcDbDatabase.SaveAs() method

I open a dwg file using AcDbDatabase.readDwgFile() and the save it back using AcDbDatabase.SaveAs(). When I open it, all tables in this drawing were changed, their style is changed to Standard and all other styles are deleted. Please help me, I don't know why. I also attach my drawing that has this problem.
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

I think drawing can't help to solve your problem. Post your code.
And tell me what context do you use "application context" or "drawing context"?
Message 3 of 5
Anonymous
in reply to: Anonymous

I use "drawing context" and my code is very simple:

AcDbDatabase *pDbDatabase;
CString sFileName = _T("D:/abc.dwg");
pDbDatabase = new AcDbDatabase();
pDbDatabase->readDwgFile(sFileName, _SH_DENYRW);
pDbDatabase->saveAs(sFileName);
delete pDbDatabase;
pDbDatabase = NULL;

This error only happens to some of my files, not all.
I use AutoCAD Electrical 2010 and these table are automatically generated by AutoCAD. Edited by: manhpham on Mar 24, 2010 10:12 AM
Message 4 of 5
Anonymous
in reply to: Anonymous

try this:
{code}
CString sFileName = _T("D:/before.dwg");
CString sFileName2 = _T("D:/before2.dwg");
AcDbDatabase *pDbDatabase = new AcDbDatabase(false,false); // your first default parameter "buildDefaultDrawing" was true
AcAxDocLock docLock(pDbDatabase);
es = pDbDatabase->readDwgFile(sFileName);
es = pDbDatabase->saveAs(sFileName2);
delete pDbDatabase;
pDbDatabase = NULL;
{code}

and don't forget
#include "axlock.h" Edited by: Nick1983 on Mar 24, 2010 1:45 PM
Message 5 of 5
Anonymous
in reply to: Anonymous

Thank you very much. I change from using default parameter values (true, false) to (false, false) and It works as I expect.

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

Post to forums  

Autodesk Design & Make Report

”Boost