ATTRIB および MTEXT オブジェクトの設定
Contents
[
Hide
]ATTRIB および MTEXT オブジェクトの設定
Aspose.CAD for .NET API を使用すると、DXF AutoCAD ファイル内の Attribute を設定できます。Aspose.CAD API では、DXF AutoCAD ファイル内のテキストエンティティを表す CadText クラスが公開されています。また、他のエンティティにもテキストが含まれる場合があるため、CadMText クラスも Aspose.CAD API に含まれています。複数の段落のテキストを単一の複数行テキスト (mtext) オブジェクトとして作成できます。以下は、Attribute および MTEXT オブジェクトを設定するためのコードのデモです。このコードスニペットは自己説明的です。
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
// The path to the documents directory. | |
string MyDir = RunExamples.GetDataDir_DXFDrawings(); | |
string sourceFilePath = MyDir + "conic_pyramid.dxf"; | |
List<CadBaseEntity> mtextList = new List<CadBaseEntity>(); | |
List<CadBaseEntity> attribList = new List<CadBaseEntity>(); | |
using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) | |
{ | |
foreach (var entity in cadImage.Entities) | |
{ | |
if (entity.TypeName == CadEntityTypeName.MTEXT) | |
{ | |
mtextList.Add(entity); | |
} | |
if (entity.TypeName == CadEntityTypeName.INSERT) | |
{ | |
foreach (var childObject in entity.ChildObjects) | |
{ | |
if (childObject.TypeName == CadEntityTypeName.ATTRIB) | |
{ | |
attribList.Add(childObject); | |
} | |
} | |
} | |
} | |
Assert.AreEqual(6, mtextList.Count); | |
Assert.AreEqual(34, attribList.Count); | |
} | |
} | |
} | |
} |