ThinkGeo.com    |     Documentation    |     Premium Support

Create DXF file for layer export

Hi, we are reading DXF files generally quite well, but would also like to export from other layer types to DXF files. My preferred way would be create a CADFeatureLayer(dxfFilePath) and add the features straight to that, however I don’t think we can create a writeable CADFeatureLayer? As an alternative I am trying the netDXF nuget package but I am not sure the best way to define a polygon, especially one with inners.

Regards,
Jonathan

Hi Jonathan,

You are right CADFeatureLayer is read only. I never used netDXF before and it does seem a pretty good package. It supports varies CAD versions, read and write, and supports .NET Core so cross platform. Its source code looks clean and just runs after cloning without any surprise.

I see many classes in the project and it must have a steep learning curve. Sorry I cannot help too much as we don’t have much experience on it. I don’t know its performance, compatibilities or everything but if that works fine, I think we can take it as our new CAD engine in the future. I’ve logged it down.

Sorry again for not being able to help too much on this. I hope you can figure it out soon and if you want, you can create your own CustomedCadFeatureLayer inheriting from FeatureLayer and use netDXF internally as the engine.

Thanks,
Ben

Hi Ben,

Thanks, I had not thought of making our own custom CAD layer and not too keen to do that at the moment - but nice idea. In general do you know what feature type a polygon is in DXF and if there are any quirks - such as making the first and last points the same?

Regards,
Jonathan

Hi Jonathan,

I am pretty green in DXF not sure if I can help too much. But anyway, here is what I learned about polygons

Here are the entities in DXF and from the comments, it seems polygon in DXF can be treated as a POLYLINE. In netDXF each entity has a class with the same name, I think you can play with Hatch/Polyline, etc classes see if you can use to create a polygon.

Generically in GIS, a Polygon is made of one outer ring and none or multiple inner rings(holes). The first and last vertex of a ring must be identical, it might be used to identify if a polyline is a ring or a line. Also in some formats (such as shapefiles) whether it’s inner ring or outer ring is identified by the order of its verticies. Verticies in an outer ring are in clockwise while those in an inner ring are always in counterclockwise. DXF might use the same trick.

Hope that helps. Good luck!

Thanks,
Ben

Hi Ben,

Thanks. Our initial implementation did use HATCH and that seemed to work OK importing into QGIS but not back into MapSuite. We also tried LWPOLYLINE but QGIS and MapSuite only see that as a line. I did try that with and without the last vertex being the same as the first vertex, but not sure if it was running clockwise.

Regards,
Jonathan

Hi Jonathan, can you upload the dxf file you created which works in QGIS but not Map Suite?

Also I bet the dxf created by netDXF can be consumed by netDXF without any issues, right? Maybe you can consider using netDXF to read/render it and embed it into ThinkGeo Framework, if that works for you.

Thanks,
Ben

mapLayers.zip (9.6 KB)

Here is the DXF file created. It is a single polygon with no inner rings but quite a lot of vertices.

Regards,
Jonathan

Thanks for the file, Jonathan! We recreated the issue but couldn’t dig in too much as we were using Teigha SDK behind the scenes and it’s beyond our reach. We converted it to dwg and it did return something but still have issues. I’m afraid we need to switch to another way. How do you think about creating a customized layer and use netDXF for both reading and writing? Let me know if you have any questions going that way.

Thanks,
Ben

Hi Ben,

I have created a few custom layers so generally OK with the idea, but unlikely to have much time to put towards this one at the moment.

Regards,
Jonathan

Hi Jonathan,

OK. Just let us know if you need any help on that.

Thanks,
Ben