Author Topic: MLeader MText Line Length  (Read 1736 times)

0 Members and 1 Guest are viewing this topic.

Jeff H

  • Needs a day job
  • Posts: 6150
MLeader MText Line Length
« on: February 25, 2012, 01:11:21 AM »
My MdbDbg craps out when selecting a Mleader so just glancing at properties how do you go about getting  the length of the line in picture.
 
This seems to work with little testing but was wondering of a better way.
 
Code - C#: [Select]
  1.  
  2.           [CommandMethod("mleaderlength")]
  3.          public void mleaderlength()
  4.          {
  5.              Document doc = Application.DocumentManager.MdiActiveDocument;
  6.              Database db = doc.Database;
  7.              Editor ed = doc.Editor;
  8.              using (Transaction trx = db.TransactionManager.StartTransaction())
  9.              {
  10.                  MLeader ml = trx.GetObject(ed.GetEntity("\nSelect ML").ObjectId, OpenMode.ForRead) as MLeader;
  11.                  Point3dCollection pnts = ml.MText.GetBoundingPoints();
  12.                  Point3d endP = pnts[2];
  13.                  double length = endP.DistanceTo(pnts[3]) +  ml.DoglegLength +  ml.LandingGap;
  14.                  ed.WriteMessage(length.ToString());
  15.  
  16.                  trx.Commit();
  17.              }
  18.          }
  19.  

fixo

  • Guest
Re: MLeader MText Line Length
« Reply #1 on: February 25, 2012, 01:55:51 AM »
What about this? not sure if this is right though
just a shot in the dark :)
Code: [Select]
ed.WriteMessage( "\nLength:\t{0}",ml.GetDoglegLength(0));
~'J'~