Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord modelSpace = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
ViewTableRecord CurrentView = ed.GetCurrentView();
var DCS2WCS = Matrix3d.Rotation(-CurrentView.ViewTwist, CurrentView.ViewDirection, CurrentView.Target) *
Matrix3d.Displacement(CurrentView.Target - Point3d.Origin) *
Matrix3d.PlaneToWorld(CurrentView.ViewDirection);
Vector3d norm
= new Vector3d
(0,
0,
1).TransformBy(DCS2WCS
); Matrix3d WCS2OCS = Matrix3d.WorldToPlane(norm);
....
text.Normal = norm;
text.Position = text.Position.TransformBy(WCS2OCS);
.....