Save dxf file in Java

I hope someone can help me here. I use the yCad library to read multiple dxf files and output the composite model to dxf format.

The initial process of reading the file is complete. However, when I save the file, it is saved without a 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 a file is viewed from the editor, an error is reported when the model is empty.

The error occurs even when the dxf file is read and then saved without manipulation.

+1
source share
1 answer

I solved this problem.

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

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

NOTE. Perhaps this is due to an outdated version of the library.

.

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

.

, , , .

+1

Source: https://habr.com/ru/post/1584748/


All Articles