Thanks kaefer. Below is what I was able to make work based on your suggestions.
[CommandMethod("LeaderTest")]
public void LeaderTest()
{
Database db = HostApplicationServices.WorkingDatabase;
Editor ed = MgdAcApplication.DocumentManager.MdiActiveDocument.Editor;
try
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
//Set up plane to control depth of MLeader
var pl = new Plane(new Point3d(0, 0, 120), new Vector3d(0, 0, 1));
//Setup Mleader object
var ml = new MLeader();
ml.SetDatabaseDefaults(db);
var l = ml.AddLeader();
var ln = ml.AddLeaderLine(l);
ml.AddFirstVertex(ln, new Point3d(0, 0, 120));
ml.AddLastVertex(ln, new Point3d(24, 36, 120));
ml.LeaderLineType = LeaderType.StraightLeader;
ml.ArrowSize = 0.125;
ml.ContentType = ContentType.NoneContent;
//Setting plane will elevate MLeader object
ml.SetPlane(pl);
//Transform matrix to set MLeader to southeast view
var toOrigin = db.Ucsorg;
var toXAxis = new Vector3d(0.707106781186548, 0.707106781186548, 0);
var toYAxis = new Vector3d(-0.408248290463863, 0.408248290463863, 0.816496580927726);
var toZAxis = toXAxis.CrossProduct(toYAxis);
var trxMatrix = Matrix3d.AlignCoordinateSystem(Point3d.Origin, Vector3d.XAxis, Vector3d.YAxis, Vector3d.ZAxis,
toOrigin, toXAxis, toYAxis, toZAxis);
ml.TransformBy(trxMatrix);
//Add MLeader to modelspace
ml.PostMLeaderToDb(db);
tr.AddNewlyCreatedDBObject(ml, true);
tr.Commit();
}
}
catch (System.Exception ex)
{
Debug.WriteLine(ex.ToString());
ed.WriteMessage(ex.ToString());
}
}
Is there a way to get the toXAxis and toYAxis vectors without hard coding them as I've done here? I was able to get these vectors by just setting the UCS in AutoCAD and checking the System Variables UCSXDIR and UCSYDIR.