Issue with saveas(sfile) in ObjectARX 2018 in a specific situation

Issue with saveas(sfile) in ObjectARX 2018 in a specific situation

3453351159
Contributor Contributor
665 Views
4 Replies
Message 1 of 5

Issue with saveas(sfile) in ObjectARX 2018 in a specific situation

3453351159
Contributor
Contributor

In a specific scenario using saveas(sfile) to save in ObjectARX 2018, after reopening the saved DWG file, it prompts that an object in a dictionary needs to be recovery. This occurs when a certain dictionary object is deleted. However, the issue does not occur if saveas(sfile,false) is used or saveas(sfile) in ObjectARX 2022.

 

 

My code like: 

 

 

auto pDb = new AcDbDatabase(false, true);
auto es = pDb->readDwgFile(sPath.c_str(), AcDbDatabase::kForReadAndReadShare);
... do something
es = pDb->saveas(sPath);

 

 

The above code runs in an environment with current document and workingdatabase.

 

How to find out why it happened?

0 Likes
666 Views
4 Replies
Replies (4)
Message 2 of 5

tbrammer
Advisor
Advisor

@3453351159 wrote:

In a specific scenario using saveas(sfile) to save in ObjectARX 2018, after reopening the saved DWG file, it prompts that an object in a dictionary needs to be recovery. This occurs when a certain dictionary object is deleted.


I hope you mean "erased" not "deleted". You must not delete objects that are DB resident.

I suppose that the erased object is still referenced within the DB. You can check references with ArxDbg's command SNOOPDB. Also the RECOVER and AUDIT command usually give hints about the objects they repair.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 3 of 5

3453351159
Contributor
Contributor

Thank you.

What I mean is that an entity has been PermanentlyErased.Below is the recovery information when open the dwg file:

图形修复。
图形修复日志。
验证句柄表内的对象。
有效对象 40544  个,无效对象 1      个
对象验证完毕。
    从图形挽回的数据库。
核查表头
核查表
第 1 阶段图元核查
阶段 1 已核查 40500   个对象
第 2 阶段图元核查
阶段 2 已核查 400     个对象AcDbDictionary(60F)
   e21f8fdcb29a405e9aa0d7c85589de ePermanentlyErased    Delete Entry
阶段 2 已核查 40500   个对象
核查块
 已核查 18      个块
正在核查 AcDsRecords
共发现 1 个错误,已修复 1 个
已删除 0 个对象
正在打开 AutoCAD 2018 格式的文件。

I think the DWG file might be corrupted, but I am unsure if there is any way to check for data issues before or after calling 'saveas'

0 Likes
Message 4 of 5

tbrammer
Advisor
Advisor

Google translators translates:


阶段 2 已核查 400 个对象AcDbDictionary(60F)
e21f8fdcb29a405e9aa0d7c85589de ePermanentlyErased Delete Entry

 

to:

 

Phase 2 checked 400 objects AcDbDictionary(60F)
e21f8fdcb29a405e9aa0d7c85589de ePermanentlyErased Delete Entry

 

So I would assume that the entity that you erased permanently is still referenced from the AcDbDictionary with handle 60F. Make sure that you remove the object from the dictionary before you erase it permanently.

 


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 5 of 5

3453351159
Contributor
Contributor

This object was not erased before saving, and it caused data corruption in the DWG file during incremental saving. When the DWG file was reopened, CAD detected an error in the file and assumed that the entity had already been erased.

 

I have also taken a test

auto pDb = new AcDbDatabase(false, true);
auto es = pDb->readDwgFile(sPath.c_str(), AcDbDatabase::kForReadAndReadShare);
... do something
es = pDb->saveas(sPath);

// a test after save
auto pNewDb = new AcDbDatabase(false, true);
auto es = pNewDb->readDwgFile(sPath.c_str(), AcDbDatabase::kForReadAndReadShare);
pNewDb->closeInput(false);
bool bNeedRevcovery = pNewDb->needsRecovery();  //The value of the variable 'bNeedRecovery' is true.
if (bNeedRevcovery)   
{
    pDb->saveAs(sPath.c_str(), false); //fully save and the dwg file is correct
}

However, this approach requires loading all entities, which takes a long time for large drawings and cannot be used in a production environment.

0 Likes