ATTRIB と MTEXT オブジェクトの設定
Contents
[
Hide
]ATTRIB と MTEXT オブジェクトの設定
Aspose.CAD for Java API を使用すると、DXF AutoCAD ファイル内の属性を設定できます。Aspose.CAD API は、DXF AutoCAD ファイル内のテキストエンティティを表す CadText クラスを公開しています。CadMText クラスは、他のエンティティもテキストを含む場合があるため、Aspose.CAD API に含まれています。複数の段落を単一の複数行テキスト (mtext) オブジェクトとして作成できます。以下は、ATTRIB と MTEXT オブジェクトを設定するためのコードのデモンストレーションです。このコードスニペットは自己説明的です。
サンプルコード
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
String srcFile = dataDir + "conic_pyramid.dxf"; | |
CadImage cadImage =(CadImage) Image.load(srcFile); | |
List<CadBaseEntity> mtextList = new ArrayList<CadBaseEntity>(); | |
List<CadBaseEntity> attribList = new ArrayList<CadBaseEntity>(); | |
try | |
{ | |
for (CadBaseEntity entity : cadImage.getEntities()) | |
{ | |
if (entity.getTypeName() == CadEntityTypeName.MTEXT) | |
{ | |
mtextList.add(entity); | |
} | |
if (entity.getTypeName() == CadEntityTypeName.INSERT) | |
{ | |
for (CadBaseEntity childObject : entity.getChildObjects()) | |
{ | |
if (childObject.getTypeName() == CadEntityTypeName.ATTRIB) | |
{ | |
attribList.add(childObject); | |
} | |
} | |
} | |
} | |
System.out.println("MText Size: "+ mtextList.size()); | |
System.out.println("Attribute Size: "+ attribList.size()); | |
} | |
finally | |
{ | |
cadImage.dispose(); | |
} | |