【发布时间】:2018-01-09 02:23:25
【问题描述】:
我正在使用 GDAL 库版本 1.11.4 开发 CAD 程序。
我有两个 DXF 文件:a.dxf 和 b.dxf。 a.dxf 是一个模板文件。该文件有一个块层。它包含一些特征(符号信息)。 b.dxf 包含一些点坐标。我应该使用符号 (a.dxf) 显示点 (b.dxf)。
我的想法:从a.dxf 导出块并将它们导入b.dxf。
但b.dxf 无法在 CAD 上打开。她是我的代码:
enter code here
#include "stdafx.h"
#include "gdal_priv.h"
#include "ogrsf_frmts.h"
#include "gdal.h"
#include "stdio.h"
int main()
{
const char *pszDriverName = "DXF";
OGRSFDriver *poDriver = nullptr;
RegisterOGRDXF();
CPLSetConfigOption("GDAL_DATA", "./debug/data");
CPLSetConfigOption("DXF_INLINE_BLOCKS", "false");
poDriver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName("DXF");
if (poDriver == NULL)
{
printf("%s driver not available.\n", pszDriverName);
exit(1);
}
OGRDataSource* poDS = OGRSFDriverRegistrar::Open("a.dxf", true, &poDriver);
//the block layer
OGRLayer* blockLayer = poDS->GetLayer(0);
OGRFeature* copy = blockLayer->GetFeature(0);
OGRDataSource* poDS1 = poDriver->CreateDataSource("b.dxf");
OGRLayer* blockLayer1 = poDS1->CreateLayer("blocks");
OGRLayer* entityLayer1 = poDS1->CreateLayer("entites");
auto err1 = blockLayer1->CreateFeature(copy);
OGRFeature::DestroyFeature(copy);
OGRDataSource::DestroyDataSource(poDS);
OGRDataSource::DestroyDataSource(poDS1);
}
有人知道问题出在哪里吗?
【问题讨论】: