DXF 생성

DXF 생성 방법

문제: DXF를 생성하는 방법.

팁: 이를 위해 LINE, CIRCLE, ARC, TEXT, POINT, SOLID, 3DFACE 및 POLYLINE과 같은 다양한 객체를 사용하여 도형을 렌더링할 수 있으며, 그 후 도형을 엔티티로 추가하는 것을 잊지 마십시오.

참고: 우리는 처음부터 DXF 파일을 생성하는 기능을 가지고 있습니다. 기본적으로 AC109 파일 형식을 사용하지만 다른 파일 버전을 지정할 수 있는 옵션이 있습니다.

예제:

DxfImage dxfImage = new DxfImage();
//LINE, CIRCLE, ARC, TEXT, POINT, SOLID, 3DFACE and POLYLINE
//add line
CadLine line = new CadLine(new Cad3DPoint(0, 0, 0), new Cad3DPoint(100, 100, 100));
dxfImage.AddEntity(line);
//add circle
CadCircle circle = new CadCircle(new Cad3DPoint(50, 0), 10);
dxfImage.AddEntity(circle);
//add arc
CadArc arc = new CadArc(new Cad3DPoint(100, 0), 10, 45, 135);
dxfImage.AddEntity(arc);
CadText text = new CadText();
text.FirstAlignment = new Cad3DPoint(0, -50, 0);
text.TextHeight = 10;
text.DefaultValue = "text value";
dxfImage.AddEntity(text);
CadPoint point = new CadPoint();
point.CenterPoint = new Cad3DPoint(-10, -10, -10);
dxfImage.AddEntity(point);
CadSolid solid = new CadSolid();
solid.FirstCorner = new Cad3DPoint(200, 200, 0);
solid.SecondCorner = new Cad3DPoint(210, 200, 0);
solid.ThirdCorner = new Cad3DPoint(210, 220, 0);
solid.FourthCorner = new Cad3DPoint(200, 220, 0);
dxfImage.AddEntity(solid);
Cad3DFace cad3DFace = new Cad3DFace();
cad3DFace.FirstCorner = new Cad3DPoint(-200, 200, 0);
cad3DFace.SecondCorner = new Cad3DPoint(-210, 200, 0);
cad3DFace.ThirdCorner = new Cad3DPoint(-210, 220, 0);
cad3DFace.FourthCorner = new Cad3DPoint(-200, 220, 0);
dxfImage.AddEntity(cad3DFace);
CadPolyline polyline = new CadPolyline();
polyline.VerticesFollowFlag = 1;
var vertex1 = new Cad2DVertex() { LocationPoint = new Cad3DPoint(20, 0) };
var vertex2 = new Cad2DVertex() { LocationPoint = new Cad3DPoint(40, -40) };
var vertex3 = new Cad2DVertex() { LocationPoint = new Cad3DPoint(60, -40) };
dxfImage.AddEntity(polyline);
dxfImage.AddEntity(vertex1);
dxfImage.AddEntity(vertex2);
dxfImage.AddEntity(vertex3);
CadSeqend seqend = new CadSeqend();
dxfImage.AddEntity(seqend);
//Color example
CadLine lineColor = new CadLine(new Cad3DPoint(0, 0, 0), new Cad3DPoint(-100, 0, 100));
dxfImage.AddEntity(lineColor);
lineColor.ColorId = 15; //ACI color id
//polyline style example
CadPolyline polylineStyle = new CadPolyline();
polylineStyle.VerticesFollowFlag = 1;
polyline.StartWidth = 3;
polyline.EndWidth = 3;
var vertex1Style = new Cad2DVertex() { LocationPoint = new Cad3DPoint(-20, 0) };
var vertex2Style = new Cad2DVertex() { LocationPoint = new Cad3DPoint(-40, -40) };
var vertex3Style = new Cad2DVertex() { LocationPoint = new Cad3DPoint(-60, -40) };
dxfImage.AddEntity(polylineStyle);
dxfImage.AddEntity(vertex1Style);
dxfImage.AddEntity(vertex2Style);
dxfImage.AddEntity(vertex3Style);
CadSeqend seqendStyle = new CadSeqend();
dxfImage.AddEntity(seqendStyle);
dxfImage.Save(fileResult);