This is a sample to show you the mathematics. It's as simple as it can be, only supporting Single Line Of Text.
Attached are samples before and after executing the sample below.
[CommandMethod("TestNewRotatedText")]
public static void TestNewRotatedText()
{
Document doc = null;
Database db = null;
Editor ed = null;
try
{
doc = AcadApp.DocumentManager.MdiActiveDocument;
db = doc.Database;
ed = doc.Editor;
var per = ed.GetEntity("Select (Single) Text");
if (per.Status != PromptStatus.OK)
{
return;
}
using (var tr = db.TransactionManager.StartTransaction())
{
var ms = (BlockTableRecord)tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForRead);
var text = tr.GetObject(per.ObjectId, OpenMode.ForRead) as DBText;
if (text == null)
{
throw new System.Exception("No (Single) Text selected");
}
var textPos = text.Position;
var textHeight = text.Height;
var textAngle = text.Rotation;
var textAlignPos = text.AlignmentPoint;
var textLineSeparation = 2.0; //or use a percentage of textHeight
var textDistance = textHeight + textLineSeparation;
var dx = textDistance * Math.Sin(textAngle);
var dy = textDistance * Math.Cos(textAngle);
var textPos2 = new Point3d(textPos.X + dx, textPos.Y - dy, 0);
var text2 = (DBText)text.Clone();
ms.UpgradeOpen();
ms.AppendEntity(text2);
tr.AddNewlyCreatedDBObject(text2, true);
text2.Position = textPos2;
if (textAlignPos != Point3d.Origin)
{
text2.AlignmentPoint = new Point3d(textAlignPos.X + dx, textAlignPos.Y - dy, 0);
}
text2.TextString = "Next Line of Text";
tr.Commit();
}
}
catch (System.Exception ex)
{
if (ed != null)
{
ed.WriteMessage("\n" + ex.Message + "\n");
}
}
}