DWG/DXFからのテーブルの読み取り
Contents
[
Hide
]DWG/DXFからテーブルを読み取る方法
問題: DWG/DXFからテーブルを読み取る方法。
ヒント: これを行うには、loadメソッドを使用してファイルを取得し、必要なエンティティを取得できます。
注意: このコードスニペットは、テーブルを取得し、それらから値を取得する例を示しています。この方法で、ファイルのテーブルに記載された値を取得できます。
例:
This file contains hidden or 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
using var cadImage = (CadImage)Image.Load(GetFileFromDesktop(fileName1)); | |
List<CadBlockEntity> tableBlocks = new List<CadBlockEntity>(); | |
var entitys = cadImage.BlockEntities.ValuesTyped; | |
foreach (CadBlockEntity entity in entitys) | |
{ | |
if (entity.Name.StartsWith("*T")) | |
{ | |
tableBlocks.Add(entity); | |
} | |
} | |
var textElements = tableBlocks.FirstOrDefault().Entities; | |
foreach (var entity in textElements) | |
{ | |
if (entity.TypeName == CadEntityTypeName.TEXT) | |
{ | |
System.Console.WriteLine("Table Text " + (entity as CadText).DefaultValue); | |
} | |
if (entity.TypeName == CadEntityTypeName.MTEXT) | |
{ | |
System.Console.WriteLine("Table Mtext " + (entity as CadMText).FullClearText); | |
} | |
} |