Save dxf file in Java

被刻印的时光 ゝ 提交于 2019-12-13 18:28:18

问题


I am hoping that someone can help me here. I am using the yCad library to read a number of dxf files and output a composite model, to dxf format.

The initial process of reading the file is complete. However, when I save the file it is saved without the model.

Here is an example of the code used to save the dxf file

public static boolean SaveDxf(String outputPath, String fileName, Yxxf model)
{
    try
    {
        model.iohandler = new YutilIOHandler();
        model.ioname = new YutilIOHandlerName(fileName);
        model.ioname.dstfile = outputPath + "\\" + fileName + ".dxf";
        YdxfPutHandler handler = new YdxfPutHandler();
        handler.commandPutMainStart(model.iohandler, model);
        return true;
    }
    catch(Exception ex)
    {
        System.out.println("failed to save dxf file: " + ex.getMessage());
        return false;
    }
}

When the file is viewed from an editor an error is reported stating the model is empty.

The error occurs even when a dxf file is read and then saved with no manipulation.


回答1:


I have resolved this issue.

The resolution required a modification to the version of the YCad library that I was using due the following selection.

if (ent instanceof YxxfEntLine)
{
    YdxfPutEntLine.put(putbfr, (YxxfEntLine)ent);
}

NOTE: This may have been due to an out of date version of the library.

The method was modified to include all required types.

else if(ent instanceof YxxfEntPolyline)
{
    YdxfPutPolyline.put(putbfr, (YxxfEntPolyline)ent);
}

A number of new classes were added to the solution.

When I get time I will see if I can submit these modification to the source library, if they are required.



来源:https://stackoverflow.com/questions/23801956/save-dxf-file-in-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!