i guess i should have pasted the copy from the example rather than posting the url to the example. i am starting with a NEW dxf file, not loading an existing one. the code below is what i’m looking at. i am drawing the example from the tutorial code, with some modifications to force the entities visible and distinguishable. as you can see, the mtext simply shows a tiny veritcal line.
//LINE, CIRCLE, ARC, TEXT, POINT, SOLID, 3DFACE and POLYLINE
//add line
CadLine line = new(new Cad3DPoint(0, 0, 0), new Cad3DPoint(100, 100, 100))
{
LineWeight = 3,
ColorValue = global::Aspose.CAD.Color.Orange.ToArgb()
};
dxfImage.AddEntity(line);
//add circle
CadCircle circle = new(new Cad3DPoint(50, 0), 10)
{
LineWeight = 3,
ColorValue = global::Aspose.CAD.Color.Blue.ToArgb()
};
dxfImage.AddEntity(circle);
//add arc
CadArc arc = new(new Cad3DPoint(100, 0), 10, 45, 135)
{
ColorValue = global::Aspose.CAD.Color.OrangeRed.ToArgb(),
LineWeight = 3,
};
dxfImage.AddEntity(arc);
CadText text = new()
{
FirstAlignment = new Cad3DPoint(0, -50, 0),
TextHeight = 10,
ColorValue = global::Aspose.CAD.Color.Black.ToArgb(),
DefaultValue = "text value"
};
dxfImage.AddEntity(text);
CadPoint point = new()
{
CenterPoint = new Cad3DPoint(-10, -10, -10),
ColorValue = global::Aspose.CAD.Color.Green.ToArgb(),
LineWeight = 3,
Radius = 4,
};
dxfImage.AddEntity(point);
CadMText watermark = new()
{
ColorValue = global::Aspose.CAD.Color.Red.ToArgb(),
Text = "Watermark message",
InitialTextHeight = 10,
InsertionPoint = new Cad3DPoint(100, 40),
LayerName = "0"
};
//dxfImage.BlockEntities["*Model_Space"].AddEntity(watermark); < -throws error
dxfImage.AddEntity(watermark); // <- end up with a single horizontal line
using var stream = new MemoryStream();
dxfImage.UpdateSize();
dxfImage.Save(stream, new PngOptions
{
VectorRasterizationOptions = new CadRasterizationOptions()
{
AutomaticLayoutsScaling = true,
BackgroundColor = Aspose.CAD.Color.White,
DrawColor = Aspose.CAD.Color.Blue,
DrawType = CadDrawTypeMode.UseObjectColor,
PageHeight = 640,
PageWidth = 640,
NoScaling = false,
ScaleMethod = ScaleType.ShrinkToFit
}
});
var png = $"data:image/png;base64,{Convert.ToBase64String(stream.ToArray())}";
image.png (2.2 KB)