Author Topic: Read dimension text  (Read 691 times)

0 Members and 1 Guest are viewing this topic.

Offline fixo

  • Full Member
  • ***
  • Posts: 135
  • Karma: +4/-0
  • Gender: Male
    • prefered language: C
    • Prog expertise: Good
    • View Profile
Read dimension text
« on: December 29, 2012, 06:32:41 PM »
 
Code: [Select]
       [CommandMethod("GetDimText","gd", CommandFlags.UsePickSet)]
        public void getDimText()
        {
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;

            Database db = doc.Database;

            Editor ed = doc.Editor;

            Transaction tr = doc.TransactionManager.StartTransaction();

            using (tr)
            {
                PromptEntityOptions peo = new PromptEntityOptions("\nSelect dimension >>");

                peo.SetRejectMessage("\nSelect dimension only >>");

                peo.AddAllowedClass(typeof(Dimension), false);

                PromptEntityResult res;

                res = ed.GetEntity(peo);

                if (res.Status != PromptStatus.OK)

                    return;

                Entity ent = (Entity)tr.GetObject(res.ObjectId, OpenMode.ForRead);

                if (ent == null)

                    return;

                Dimension dim = (Dimension)ent as Dimension;

                if (dim != null)
                {
                   
                    ed.WriteMessage("\nDim measurement:\t{0}",dim.Measurement);

                    if (dim.DimensionText != "") ed.WriteMessage("\nHas overriden dim text:\t{0}", dim.DimensionText);
           
                }

                tr.Commit();
            }//end using transaction
        }