设置 ATTRIB 和 MTEXT 对象
Contents
[
Hide
]设置 ATTRIB 和 MTEXT 对象
Aspose.CAD for Java API 允许您在 DXF AutoCAD 文件中设置属性。Aspose.CAD API 提供了 CadText 类,该类表示 DXF AutoCAD 文件中的文本实体。类 CadMText 被包含在 Aspose.CAD API 中,因为其他一些实体也可能包含文本。您可以将几段文本作为一个单独的多行文本 (mtext) 对象来创建。以下是设置属性和 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(); | |
} | |