[gdal-dev] Save to DXF with specific layer name with c#

Andreas Neumann a.neumann at carto.net
Fri Jul 30 08:31:21 EDT 2010


Hi Colin,

Not sure if creation of layers is yet supported. I think it is only
supported if you created the layers in advance in the header.dxf file.

Frank Warmerdam is now working on a second round of improvements where
automatic layer creation (even if the layers aren't present in header.dxf)
should be supported.

You probably have to wait for a couple weeks for this to appear.

Frank can tell you more about it.

Andreas


On Fri, July 30, 2010 11:21 am, Colin Wright wrote:
> I'm using GDAL/OGR 1.7.2 with the C# bindings to write a tool that will
> export data to various formats.
>
> When it exports to DXF I want it to use a specific layer name rather than
> using the default dxf layer 0.
> The problem is that even though I'm setting the attribute "Layer" for each
> feature, it is still appearing as layer 0 in the final DXF file.  I've
> checked and the "Layer" attribute does exist, and setting the attribute
> value doesn't throw any errors.  The geometry is getting saved to the DXF
> OK.
>
> Any ideas?  An extract of my code is below.
>
> //--------------------------------------------------
> //Loop through input layers writing to output
> lyrInput.ResetReading();
> Feature inFeat = lyrInput.GetNextFeature();
> iError = -1;
> while (inFeat != null)
> {
>                //Try approach of creating new feature
> 	Feature outFeat = new Feature(lyrOutput.GetLayerDefn());
>                 if (outFeat.SetGeometry(inFeat.GetGeometryRef()) ==
> Ogr.OGRERR_NONE)
>                {
>                        bFeatOK = true;
>
>                       //Generic attribs for DXF
>                       if (sOutFormat == "DXF")
>                       {
>                                   //I've checked and this section is
> getting called
>                                   outFeat.SetField("Layer",
> "MyLayerName");
>
>                        }
>                }
>                if (bFeatOK)
>                {
> 	         iError = lyrOutput.CreateFeature(outFeat);
>                }
>
>                outFeat.Dispose();
>                inFeat = lyrInput.GetNextFeature();
> }
>
>
> Thanks
>
> Colin
>
>
> --------------------------------
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>


-- 
Andreas Neumann
http://www.carto.net/neumann/
http://www.svgopen.org/



More information about the gdal-dev mailing list