用Java保存DXF文件 [英] Save dxf file in Java

查看:577
本文介绍了用Java保存DXF文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人可以在这里帮助我.我正在使用yCad库读取许多dxf文件,并将复合模型输出为dxf格式.

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.

这是用于保存dxf文件的代码示例

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.

即使读取dxf文件,然后在没有任何操作的情况下保存,也会发生错误.

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

推荐答案

我已经解决了此问题.

I have resolved this issue.

由于以下选择,该分辨率要求修改我正在使用的YCad库的版本.

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.

这篇关于用Java保存DXF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆