java dxf文件,用Java保存DXF文件

博主在使用YCad库读取并组合多个DXF文件后,发现保存的文件模型为空。问题源于YCad库的版本过旧,缺少对特定类型的支持。通过对源代码的修改,增加了对YxxfEntLine和YxxfEntPolyline等类型的处理,成功解决了模型丢失的问题。修复后的代码能正确保存包含所有必要类型的DXF文件。
摘要由CSDN通过智能技术生成

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.

解决方案

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.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值