Ustawianie obiektów ATTRIB i MTEXT
Ustawianie obiektów ATTRIB i MTEXT
Aspose.CAD dla .NET API umożliwia ustawienie Atrybutu w pliku DXF AutoCAD. Aspose.CAD API udostępnia klasę CadText, która reprezentuje jednostki tekstowe w pliku DXF AutoCAD. Klasa CadMText jest zawarta w Aspose.CAD API, ponieważ niektóre inne jednostki mogą również zawierać tekst. Możesz utworzyć kilka akapitów tekstu jako pojedynczy obiekt tekstu wieloliniowego (mtext). Poniżej znajduje się demonstracja kodu dotycząca ustawiania obiektów Atrybutów i MTEXT. Fragment kodu mówi sam za siebie.
// 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); | |
} | |
} | |
} | |
} |