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(...) |