Impostazione degli oggetti ATTRIB e MTEXT
Impostazione degli oggetti ATTRIB e MTEXT
Aspose.CAD per Java API consente di impostare l’Attributo in un file DXF di AutoCAD. L’API Aspose.CAD espone la class CadText che rappresenta le entità di testo nel file DXF di AutoCAD. La classe CadMText è inclusa nell’API Aspose.CAD perché alcune altre entità possono contenere testo. Puoi creare diversi paragrafi di testo come un singolo oggetto di testo su più righe (mtext). Di seguito è riportata la dimostrazione del codice per impostare gli oggetti Attributo e MTEXT. Il frammento di codice è autoesplicativo.
Codice Esempio
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(); | |
} | |