ライブラリを使用した単純なJavaパッケージは、DXFファイルを派生し、他のサードパーティ製のインターフェースを使用せずに、現在の出力ポイント、ポリライン、テキストの一行、ブロック層、原始的な色をサポートするための変更をサポートし、ブロックは、(カスタムプロパティをサポートしています拡張プロパティブロックは、属性フィールドは、)を追加するカスタマイズされた凸部のポリラインは従事した後、他の要素を描画するために自由にフォローアップ機能をアップグレードする手掛かりを計算することができません。。。
プロシージャを呼び出し、次のとおりです。
DXFDocument dxfDocument = DXFDocument.newInstance();
//region 定义图层
//初始化线图层
LayerTableEntity lineLayer = new LayerTableEntity("line");
//设置图层颜色
lineLayer.setLayerColorIndex(2);
//定义图层到文档
dxfDocument.createLayer(lineLayer);
//初始化点图层
LayerTableEntity pointLayer = new LayerTableEntity("point");
//设置图层颜色
pointLayer.setLayerColorIndex(10);
//定义图层到文档
dxfDocument.createLayer(pointLayer);
//endregion
//region 定义块
BlockCustom blockCustom = new BlockCustom(dxfDocument, "WEIPI");
//块内容定义
LWPolyLineEntity lwPolyLineEntity = new LWPolyLineEntity(0, 0, 0);
lwPolyLineEntity.addDXFPoint(new DXFPoint(0.1, 0, 0));
lwPolyLineEntity.addDXFPoint(new DXFPoint(-0.1, 0, 0));
lwPolyLineEntity.setWidth(0.2);
blockCustom.addEntity(lwPolyLineEntity);
//块属性定义
Att attPointName = new Att("x", "0");
Att attPointHeight = new Att("y", "0");
blockCustom.addAtt(attPointName);
blockCustom.addAtt(attPointHeight);
blockCustom.addAtt( new Att("PointName", "Point-1"));
//定义块到文档中
dxfDocument.defineBlock(blockCustom);
//endregion
//region 线、块绘制
Random random = new Random();
//产生100条多段线每条线50个点,颜色随机,
for (int j = 1; j <= 20; j++) {
LWPolyLineEntity polyLineEntity = new LWPolyLineEntity(0, 0, 0);
polyLineEntity.setLayer(lineLayer);
polyLineEntity.setColor(random.nextInt(240));
for (int i = 0; i < 50; i++) {
double x = i * j;
double y = 10 * Math.sin(i * j) + j * 10;
polyLineEntity.addDXFPoint(new DXFPoint(x, y, 0));
BlockEntity blockEntity = new BlockEntity(dxfDocument, x, y, 0.0, blockCustom);
blockEntity.setLayer(pointLayer);
//添加属性
Att pn = new Att("PointName", "Point" + j + "-" + i);
pn.setTextColorIndex(random.nextInt(240));
Att xAtt = new Att("x", x + "");
//设置该属性不显示到图中
xAtt.setAttStatus(Att.ATT_STATUS_UNVISIBLE);
Att yAtt = new Att("y", y + "");
yAtt.setAttStatus(Att.ATT_STATUS_UNVISIBLE);
blockEntity.addAtt(xAtt);
blockEntity.addAtt(yAtt);
blockEntity.addAtt(pn);
blockEntity.setTextColorIndex(random.nextInt(240));
dxfDocument.addEntity(blockEntity);
}
dxfDocument.addEntity(polyLineEntity);
}
//endregion
try {
dxfDocument.writeToDXF("78.dxf");
} catch (Exception e) {
e.printStackTrace();
}
ファイルのプレビュー
詳細:
プロパティを表示します
少し大きな5Mファイル