Einstellung von ATTRIB- und MTEXT-Objekten
Einstellung von ATTRIB- und MTEXT-Objekten
Aspose.CAD für .NET API ermöglicht es Ihnen, Attribute in einer DXF AutoCAD-Datei festzulegen. Die Aspose.CAD API stellt die CadText Klasse zur Verfügung, die Textentitäten in der DXF AutoCAD-Datei darstellt. Die CadMText Klasse ist in der Aspose.CAD API enthalten, da einige andere Entitäten ebenfalls Text enthalten können. Sie können mehrere Textabsätze als ein einzelnes mehrzeiliges Text- (mtext) Objekt erstellen. Im Folgenden finden Sie eine Code-Demonstration zur Einstellung von Attribut- und MTEXT-Objekten. Der Code-Snippet ist selbsterklärend.
// 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); | |
} | |
} | |
} | |
} |