Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
CFileDialog fileDlg(FALSE, L"dxf", L"output", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, L"DXF Files (*.dxf)|*.dxf||", NULL);
if (fileDlg.DoModal() != IDOK)
{
return;
}
CString filePath = fileDlg.GetPathName();
AcDbDatabase* tempDb = new AcDbDatabase();
if (!tempDb)
{
return;
}
AcDbBlockTable* blockTable;
acdbHostApplicationServices()->workingDatabase()->getBlockTable(blockTable, AcDb::kForRead);
AcDbBlockTableRecord* modelSpace;
blockTable->getAt(ACDB_MODEL_SPACE, modelSpace, AcDb::kForRead);
blockTable->close();
AcDbBlockTableRecordIterator* iter;
modelSpace->newIterator(iter);
for (; !iter->done(); iter->step())
{
AcDbEntity* entity;
if (iter->getEntity(entity, AcDb::kForRead) == Acad::eOk)
{
if (wcscmp(entity->layer(), mLayerName) == 0)
{
AcDbEntity* clonedEntity = static_cast<AcDbEntity*>(entity->clone());
AcDbBlockTable* tempBlockTable = nullptr;
Acad::ErrorStatus es = tempDb->getBlockTable(tempBlockTable, AcDb::kForWrite);
if (es != Acad::eOk || !tempBlockTable)
{
delete tempDb;
return;
}
AcDbBlockTableRecord* tempModelSpace;
tempBlockTable->getAt(ACDB_MODEL_SPACE, tempModelSpace, AcDb::kForWrite);
tempBlockTable->close();
tempModelSpace->appendAcDbEntity(clonedEntity);
clonedEntity->close();
tempModelSpace->close();
}
entity->close();
}
}
delete iter;
modelSpace->close();
if (tempDb->dxfOut(filePath, 16, AcDb::kDHL_CURRENT, false) != Acad::eOk)
{
MessageBox(L"error");
}
else
{
MessageBox(L"Success");
}
delete tempDb;
In the attached file Drawing1.dwg, there are two lines - one short and one long. I copy one of the lines to a new layer and export all objects from this new layer to a DXF file.
The issue I'm encountering is:
When I copy only the short line and export, the DXF file (attached output.dxf) works correctly.
However, when I copy only the long line and export, the resulting DXF file (attached output2.dxf) appears to be corrupted.
Notably, tempDb->dxfOut always returns Acad::eOk in both cases.
Solved! Go to Solution.