Tring to read DXF file , draw line, Add Text and save it in dxf format.
After saving the file it’s not visible in https://viewer.autodesk.com/
DXF Error.jpg (122.9 KB)
public void SaveDXF()
{
var timestamp = DateTime.Now.ToString(“yyyyMMddHHmmss”);
//Create Image instance and initialize it with an existing image file from disk location
using ( Image image = Image.Load(@“Dwg\Selected\conic_pyramid.dxf”))
{
string strLayoutName = string.Empty;
Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)image;
CadText cadText = new CadText();
cadText.StyleType = "Standard";
cadText.DefaultValue = "Test Text";
cadText.LineWeight = 8;
cadText.FirstAlignment.X = 15;
cadText.FirstAlignment.Y = 10;
cadText.TextHeight = 0.2;
cadText.ScaleX = 0.0;
//cadImage.BlockEntities["*Model"].AddEntity(cadText);
CadLine line = new CadLine(new Cad3DPoint(0, 0, 0), new Cad3DPoint(100, 100, 0));
line.ColorId = 150;
// Change the type of cadImage.Entities to List<CadEntityBase>
List<CadEntityBase> entities = new List<CadEntityBase>();
// Add the line to the entities collection
entities.Add(line);
entities.Add(cadText);
// Assign the entities collection to cadImage.Entities
cadImage.Entities = entities;
DxfOptions options = new DxfOptions();
options.TextAsLines = true;
options.ConvertTextBeziers = true;
options.BezierPointCount = 20;
cadImage.Save($"output\\{timestamp}_SaveInDXF_WithText.dxf", options);
}
}