DWG 생성
Contents
[
Hide
]DWG 파일 생성 방법
문제: DWG 파일을 생성하는 방법.
팁: DWG 파일을 생성하려면 LINE, CIRCLE, ARC, TEXT, POINT, SOLID, 3DFACE, POLYLINE과 같은 다양한 도형 개체를 활용할 수 있습니다. 이러한 개체를 정의한 후에는 이들이 도면의 엔티티로 추가되었는지 확인해야 합니다.
참고: 저희 소프트웨어는 DWG 파일을 처음부터 끝까지 생성할 수 있는 강력한 기능을 제공하여, 복잡한 도면을 쉽게 설계하고 정의할 수 있게 해줍니다.
예시:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DwgImage dwgImage = new DwgImage(); | |
//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)); | |
dwgImage.AddEntity(line); | |
//add circle | |
CadCircle circle = new CadCircle(new Cad3DPoint(50, 0), 10); | |
dwgImage.AddEntity(circle); | |
//add arc | |
CadArc arc = new CadArc(new Cad3DPoint(100, 0), 10, 45, 135); | |
dwgImage.AddEntity(arc); | |
CadText text = new CadText(); | |
text.FirstAlignment = new Cad3DPoint(0, -50, 0); | |
text.TextHeight = 10; | |
text.DefaultValue = "text value"; | |
dwgImage.AddEntity(text); | |
CadPoint point = new CadPoint(); | |
point.CenterPoint = new Cad3DPoint(-10, -10, -10); | |
dwgImage.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); | |
dwgImage.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); | |
dwgImage.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) }; | |
dwgImage.AddEntity(polyline); | |
dwgImage.AddEntity(vertex1); | |
dwgImage.AddEntity(vertex2); | |
dwgImage.AddEntity(vertex3); | |
CadSeqend seqend = new CadSeqend(); | |
dwgImage.AddEntity(seqend); | |
//Color example | |
CadLine lineColor = new CadLine(new Cad3DPoint(0, 0, 0), new Cad3DPoint(-100, 0, 100)); | |
dwgImage.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) }; | |
dwgImage.AddEntity(polylineStyle); | |
dwgImage.AddEntity(vertex1Style); | |
dwgImage.AddEntity(vertex2Style); | |
dwgImage.AddEntity(vertex3Style); | |
CadSeqend seqendStyle = new CadSeqend(); | |
dwgImage.AddEntity(seqendStyle); | |
dwgImage.Save("fileResult.dwg"); |