Ustalanie obiektów ATTRIB i MTEXT
Ustalanie obiektów ATTRIB i MTEXT
Aspose.CAD dla Java API umożliwia ustawienie atrybutu w pliku DXF AutoCAD. API Aspose.CAD udostępnia CadText klasę, która reprezentuje encje tekstowe w pliku DXF AutoCAD. Klasa CadMText jest zawarta w API Aspose.CAD, ponieważ niektóre inne encje mogą również zawierać tekst. Możesz utworzyć kilka akapitów tekstu jako pojedynczy obiekt tekstowy wielowierszowy (mtext). Poniżej znajduje się demonstracja kodu ustalania atrybutów i obiektów MTEXT. Fragment kodu jest samowyjaśniający.
Przykładowy kod
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(); | |
} | |