DXF 안에 DXF/DWG 도면 삽입하기
Contents
[
Hide
]DXF 안에 DXF/DWG 도면 삽입하는 방법
문제: DXF 안에 DXF/DWG 도면을 삽입하는 방법.
팁: 이를 위해서는 먼저 필요한 값으로 CadInsertObject를 생성한 다음, CadBlockDictionary에서 모든 블록을 가져오고, 새로운 CadBlockEntity 블록을 생성하여 CadBlockDictionary에 추가하고, CadBlockDictionary를 도면의 BlockEntities에 추가하고, 배열을 위해 도면의 엔티티에 CadInsertObject를 추가해야 합니다.
예제:
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
/ this part is not required but detects the first available free ID for handle as each object should have unique one | |
// assuming that we only make export, but not saving to dxf/dwg, you may assign any unique value | |
string newObjectID = "FFFFFF"; | |
if (cadImage.Header.HeaderProperties.ContainsKey(CadHeaderAttribute.HANDSEED)) | |
{ | |
newObjectID = ((CadStringParameter)cadImage.Header.HeaderProperties[CadHeaderAttribute.HANDSEED][0]).Value; | |
int nextAvailableID = int.Parse(newObjectID, System.Globalization.NumberStyles.HexNumber) + 1; | |
((CadStringParameter)cadImage.Header.HeaderProperties[CadHeaderAttribute.HANDSEED][0]).Value = nextAvailableID.ToString("X"); | |
} | |
CadInsertObject newInsert = new CadInsertObject(); | |
newInsert.Name = "foreground"; | |
newInsert.SoftOwner.Value = cadImage.Layouts["Model"].BlockTableRecordHandle; | |
newInsert.ObjectHandle = newObjectID; | |
newInsert.LayerName = "0"; | |
newInsert.InsertionPoint.X = 200; | |
newInsert.InsertionPoint.Y = -1300; | |
CadBlockDictionary allBlocks = cadImage.BlockEntities; | |
CadBlockEntity newBlock = new CadBlockEntity(); | |
newBlock.XRefPathName.Value = "foreground.dwg"; | |
allBlocks.Add(newInsert.Name, newBlock); | |
cadImage.BlockEntities = allBlocks; | |
List entities = new List(cadImage.Entities); | |
entities.Add(newInsert); | |
cadImage.Entities = entities.ToArray(); | |
cadImage.Save(...) |