DWG 내에 DXF/DWG 도면 삽입하기
Contents
[
Hide
]DWG 내에 DXF/DWG 도면 삽입하는 방법
문제: DWG 내에 DXF/DWG 도면을 삽입하는 방법.
팁: 이를 위해 먼저 필요한 값으로 CadInsertObject를 생성한 후, CadBlockDictionary에서 모든 블록을 가져오고, 새로운 CadBlockEntity 블록을 생성하여 CadBlockDictionary에 추가하며, 도면의 BlockEntities에 CadBlockDictionary를 추가하고, 배열을 위한 도면 엔티티에 CadInsertObject를 추가하고, 참조로 CadBlockTableObject를 생성한 다음, 도면에 블록을 추가합니다.
예제:
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
CadInsertObject newInsert = new CadInsertObject(); | |
newInsert.Name = "foreground"; | |
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(); | |
CadBlockTableObject blockTableObjectReference = null; | |
CadBlockEntity cadBlockEntity = null; | |
foreach (CadBlockTableObject tableObject in cadImage.BlocksTables) | |
{ | |
if (string.Equals(tableObject.HardPointerToLayout.Value, cadImage.Layouts["Model"].ObjectHandle)) | |
{ | |
blockTableObjectReference = tableObject; | |
break; | |
} | |
} | |
if (blockTableObjectReference != null && cadImage.BlockEntities.ContainsKey(blockTableObjectReference.BlockName)) | |
{ | |
cadBlockEntity = cadImage.BlockEntities[blockTableObjectReference.BlockName]; | |
} | |
List blockEntities = new List(cadBlockEntity.Entities); | |
blockEntities.Add(newInsert); | |
cadBlockEntity.Entities = blockEntities.ToArray(); | |
cadImage.Save(...) |