Opened 7 years ago
Closed 7 years ago
#6998 closed defect (invalid)
DXF block: import label block error
Reported by: | licas | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | OGR_SF | Version: | 1.11.4 |
Severity: | normal | Keywords: | dxf block import |
Cc: |
Description (last modified by )
cad version: cad2014
gdal version: 1.11.4
ide: vs2015
Precondition:source.dxf,destination.dxf
Program download link: https://drive.google.com/file/d/0BwOcIL25klCEWkdYVjA4bjdZbUE/view
Purpose: I have a source.dxf, there are one block in this file, named 10010. I want to import the block from source.dxf to destination.dxf.
I decide to use gdal ogr for this purpose.And then I get all the features from source.dxf's blocklayer, and insert all the features to destination.dxf's blocklayer. When i done, i open the destination.dxf in cad2014. But when i open the block module, i find the result is wrong.It's a wrong block(not same as source.dxf).Also i try this in gdal 2.1.3. It has the same problem.
You can download the program in the above link(I build this program in vs2015), the program includes the source.dxf and destination.dxf(AddDxfBlock\AddDxfBlock\Debug\data),you can open in the cad2014.
viewpoint:I view the gdal source code roughly. And then I find some thing in the ogrdxfwriterlayer.cpp. It has a function named WriteInsert. I find the function only resolves Symbol type(OGRSTCSymbol). And it can’t handle the label type(OGRSTCLabel). Is this a bug Or my wrong understand?
Look forward to your reply!
Change History (2)
comment:1 by , 7 years ago
Description: | modified (diff) |
---|
comment:2 by , 7 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
I found that things work properly when doing:
ogr2ogr -f dxf out.dxf AddDxfBlock/AddDxfBlock/Debug/data/source.dxf --config DXF_INLINE_BLOCKS NO --config DXF_MERGE_BLOCK_GEOMETRIES false
So the error must be in your code rather than in GDAL itself. Looking at your main.cpp, I see a flow which is the likely reason for the failure you see. You call CreateFeature() with a feature that is coming from the source layer. This is illegal. You need to instance a target feature with targetFeature = new OGRFeature(blockLayer1->GetLayerDefn()) and then use targetFeature->SetFrom(srcFeature); And then you can call blockLayer1->CreateFeature(targetFeature)