Reading a Dxf file with Java

前端 未结 3 1466
無奈伤痛
無奈伤痛 2020-12-16 17:47

I am trying to write/find some code in Java which reads dxf files and stores geometry from the \"Entities\" section into arrays so that I can later import that information i

3条回答
  •  我在风中等你
    2020-12-16 18:01

    I've used kabeja recently and haven´t had any problems, though I did quite simple tasks. If you just want to bring those geometries into an array it will do the job (in other cases I can't tell). If you already know the DXF format you will have no problems to get started. It can get as easy as follows (e.g. to extract some circle entities):

    Parser parser = ParserBuilder.createDefaultParser();
    parser.parse("path/file.dxf", DXFParser.DEFAULT_ENCODING);
    DXFDocument doc = parser.getDocument();
    DXFlayer layer = doc.getDXFLayer("layer_name");
    List arcs = layer.getDXFEntities(DXFConstants.ENTITY_TYPE_CIRCLE);
    

    The documentation is a bit incomplete, but it has decent javadocs and clean api.

提交回复
热议问题