.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get the text override data from dimension properties using c#

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
tinuthomasGE9RJ
214 Views, 2 Replies

How to get the text override data from dimension properties using c#

Hello all,

            I'm seeking for a way to find the dimension text is overridden or not! is there any way to take the text override data from a dimension properties. Can anyone help me with some sample code??

  

2 REPLIES 2
Message 2 of 3
_gile
in reply to: tinuthomasGE9RJ

Hi,

 

You can check the Dimension.DimensionText value. It is an empty string if not overriden.

 

Testing example:

        [CommandMethod("DIMTEST")]
        public static void DimTest()
        {
            var doc = Application.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var ed = doc.Editor;

            var options = new PromptEntityOptions("\nSelect Dimension: ");
            options.SetRejectMessage("\nSelected object must be a Dimension.");
            options.AddAllowedClass(typeof(Dimension), false);
            var result = ed.GetEntity(options);
            if (result.Status != PromptStatus.OK) 
                return;

            using (var tr = db.TransactionManager.StartTransaction())
            {
                var dim = (Dimension)tr.GetObject(result.ObjectId, OpenMode.ForRead);
                string dimText = dim.DimensionText;
                if (dimText == string.Empty)
                    ed.WriteMessage("\nNot overriden dimension");
                else
                    ed.WriteMessage($"\nOverriden dimension: {dimText}");
                tr.Commit();
            }
        }


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 3
tinuthomasGE9RJ
in reply to: _gile

Thank you sir...........

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report