How can you get the angle from cadmtext?

using (CadImage cadImage = (CadImage)Image.Load(openFileDialog.FileName, loadOptions))
{
for (int i = 0; i < cadImage.Entities.Length; i++)
{
CadEntityBase baseEntity = cadImage.Entities[i];
if(cadEntityBase.baseEntity== CadEntityTypeName.MTEXT)
{
CadMText cadMText = (CadMText)cadEntityBase;
var height = cadMText.HorizontalWidth;
var width = cadMText.ColumnWidth;
var rotation = cadMText.RotationAngleRad; <== I always get 0
var text = cadMText.FullClearText;
cadMText.RotationAngleRad = rotation;
}
}
}

@qor5457,
Hi.
Could you please provide sample drawing with rotated MTEXT so we can check.

Drawing1.zip (27.7 KB)

Thank you.

@qor5457,
this value cadMText.RotationAngleRad may be empty for the MTEXT in the file, in this case mtext.DirectionVector stores the direction of angle. In case both of them exist for the MTEXT the mtext.DirectionVector is reliable to calculate the angle.

1 Like