<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: I want to override the dimension Text with keeping the tolerances as it is in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/i-want-to-override-the-dimension-text-with-keeping-the/m-p/12387630#M6699</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Attaching the before and after images FYI&lt;BR /&gt;Before Image&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="varadkeshatwar_0-1700465695018.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1294897i6657CEC227881DD9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="varadkeshatwar_0-1700465695018.png" alt="varadkeshatwar_0-1700465695018.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;After Overriding the Text, I achieved the following results&lt;BR /&gt;After Image&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="varadkeshatwar_2-1700442831802.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1294829i4B54A345F390778E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="varadkeshatwar_2-1700442831802.png" alt="varadkeshatwar_2-1700442831802.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 20 Nov 2023 07:35:06 GMT</pubDate>
    <dc:creator>varad.keshatwar</dc:creator>
    <dc:date>2023-11-20T07:35:06Z</dc:date>
    <item>
      <title>I want to override the dimension Text with keeping the tolerances as it is</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-want-to-override-the-dimension-text-with-keeping-the/m-p/12357923#M6693</link>
      <description>&lt;P&gt;I want to override the dimension Text, with keeping the tolerances as it is. Is it possible?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="varadkeshatwar_0-1699297820945.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1289093iE3E83248F8C29CF3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="varadkeshatwar_0-1699297820945.png" alt="varadkeshatwar_0-1699297820945.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 19:11:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-want-to-override-the-dimension-text-with-keeping-the/m-p/12357923#M6693</guid>
      <dc:creator>varad.keshatwar</dc:creator>
      <dc:date>2023-11-06T19:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: I want to override the dimension Text with keeping the tolerances as it is</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-want-to-override-the-dimension-text-with-keeping-the/m-p/12359499#M6694</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;You can get the dimension MText contents from the BlockTableRecord of the Dimension and the measurement text from the dimension properties.&lt;/P&gt;
&lt;P&gt;Here's an example you can start from.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;        private static string GetDimensionContents(Dimension dimension) =&amp;gt;
            ((BlockTableRecord)dimension.DimBlockId.GetObject(OpenMode.ForRead))
            .Cast&amp;lt;ObjectId&amp;gt;()
            .Where(id =&amp;gt; id.ObjectClass.Name == "AcDbMText")
            .Select(id =&amp;gt; (MText)id.GetObject(OpenMode.ForRead))
            .First()
            .Contents;

        private static string GetMeasurementText(Dimension dimension) =&amp;gt;
            (dimension is LineAngularDimension2 || dimension is Point3AngularDimension) ?
            Converter.AngleToString(dimension.Measurement, (AngularUnitFormat)dimension.Dimaunit, dimension.Dimadec) :
            Converter.DistanceToString(dimension.Measurement, (DistanceUnitFormat)dimension.Dimlunit, dimension.Dimdec);&lt;/LI-CODE&gt;
&lt;P&gt;And then use Regex to replace the measurement part by another text.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;dimension.DimensionText = Regex.Replace(
    GetDimensionContents(dimension),
    GetMeasurementText(dimension),
    replacementText);&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 07 Nov 2023 10:25:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-want-to-override-the-dimension-text-with-keeping-the/m-p/12359499#M6694</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-11-07T10:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: I want to override the dimension Text with keeping the tolerances as it is</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-want-to-override-the-dimension-text-with-keeping-the/m-p/12373878#M6695</link>
      <description>&lt;P&gt;Hii&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;I'm using Stacked Dimension to override the tolerances. I'm overriding the text as follows&lt;BR /&gt;\A1;%%c316{\H0.5x;\S+0.00^-0.36;&lt;BR /&gt;by overriding dimension text as above, I get the following result&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="varadkeshatwar_1-1699883976998.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1292292i2256D1181BAFC79F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="varadkeshatwar_1-1699883976998.png" alt="varadkeshatwar_1-1699883976998.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2023 13:59:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-want-to-override-the-dimension-text-with-keeping-the/m-p/12373878#M6695</guid>
      <dc:creator>varad.keshatwar</dc:creator>
      <dc:date>2023-11-13T13:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: I want to override the dimension Text with keeping the tolerances as it is</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-want-to-override-the-dimension-text-with-keeping-the/m-p/12374136#M6696</link>
      <description>&lt;P&gt;Sorry, I don't understand what you're trying to do.&lt;/P&gt;
&lt;P&gt;Please post a 'before/after' example.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2023 15:17:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-want-to-override-the-dimension-text-with-keeping-the/m-p/12374136#M6696</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-11-13T15:17:01Z</dc:date>
    </item>
    <item>
      <title>Re: I want to override the dimension Text with keeping the tolerances as it is</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-want-to-override-the-dimension-text-with-keeping-the/m-p/12376284#M6697</link>
      <description>&lt;P&gt;Giles, could you possible explain in a step by step manner how does thank LINQ work?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2023 13:16:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-want-to-override-the-dimension-text-with-keeping-the/m-p/12376284#M6697</guid>
      <dc:creator>a.kouchakzadeh</dc:creator>
      <dc:date>2023-11-14T13:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: I want to override the dimension Text with keeping the tolerances as it is</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-want-to-override-the-dimension-text-with-keeping-the/m-p/12376532#M6698</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/10854705"&gt;@a.kouchakzadeh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Giles, could you possible explain in a step by step manner how does thank LINQ work?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;LI-CODE lang="general"&gt;        private static string GetDimensionContents(Dimension dimension) =&amp;gt;
            ((BlockTableRecord)dimension.DimBlockId.GetObject(OpenMode.ForRead))
            .Cast&amp;lt;ObjectId&amp;gt;()
            .Where(id =&amp;gt; id.ObjectClass.Name == "AcDbMText")
            .Select(id =&amp;gt; (MText)id.GetObject(OpenMode.ForRead))
            .First()
            .Contents;&lt;/LI-CODE&gt;
&lt;P&gt;stands for:&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;        private static string GetDimensionContents(Dimension dimension)
        {
            string contents = null;
            var btr = (BlockTableRecord)dimension.DimBlockId.GetObject(OpenMode.ForRead);
            foreach (ObjectId id in btr)
            {
                if (id.ObjectClass.Name == "AcDbMText")
                {
                    var mtext = (MText)id.GetObject(OpenMode.ForRead);
                    contents =  mtext.Contents;
                    break;
                }
            }
            return contents;
        }&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 14 Nov 2023 14:50:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-want-to-override-the-dimension-text-with-keeping-the/m-p/12376532#M6698</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-11-14T14:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: I want to override the dimension Text with keeping the tolerances as it is</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-want-to-override-the-dimension-text-with-keeping-the/m-p/12387630#M6699</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Attaching the before and after images FYI&lt;BR /&gt;Before Image&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="varadkeshatwar_0-1700465695018.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1294897i6657CEC227881DD9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="varadkeshatwar_0-1700465695018.png" alt="varadkeshatwar_0-1700465695018.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;After Overriding the Text, I achieved the following results&lt;BR /&gt;After Image&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="varadkeshatwar_2-1700442831802.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1294829i4B54A345F390778E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="varadkeshatwar_2-1700442831802.png" alt="varadkeshatwar_2-1700442831802.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 07:35:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-want-to-override-the-dimension-text-with-keeping-the/m-p/12387630#M6699</guid>
      <dc:creator>varad.keshatwar</dc:creator>
      <dc:date>2023-11-20T07:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: I want to override the dimension Text with keeping the tolerances as it is</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-want-to-override-the-dimension-text-with-keeping-the/m-p/12387993#M6700</link>
      <description>&lt;P&gt;It's still confusing. From what I see it is not "keeping the tolerance intact".&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="_gile_0-1700465621962.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1294896i810F410327B92FC2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="_gile_0-1700465621962.png" alt="_gile_0-1700465621962.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I stick to your request: "override the dimension Text with keeping the tolerances as it is", my first answer is correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;        [CommandMethod("TEST")]
        public void Test()
        {
            var doc = AcAp.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var ed = doc.Editor;

            var promptEntityOptions = new PromptEntityOptions("\nSelect Dimension: ");
            promptEntityOptions.SetRejectMessage("\nSelected object is not a Dimension.");
            promptEntityOptions.AddAllowedClass(typeof(Dimension), false);
            var promptEntityResult = ed.GetEntity(promptEntityOptions);
            if (promptEntityResult.Status != PromptStatus.OK) return;

            using (var tr = db.TransactionManager.StartTransaction())
            {
                var dimension = (Dimension)tr.GetObject(promptEntityResult.ObjectId, OpenMode.ForWrite);
                string currentMeasurementText = GetMeasurementText(dimension);

                var promptResult = ed.GetString(
                    $"\nCurrent mesurement = {currentMeasurementText}." +
                    "\nEnter the replacement text: ");
                if (promptResult.Status == PromptStatus.OK)
                {
                    string replacementText = promptResult.StringResult;
                    dimension.DimensionText = Regex.Replace(
                        GetDimensionContents(dimension),
                        currentMeasurementText,
                        replacementText);
                }
                tr.Commit();
            }
        }

        private static string GetDimensionContents(Dimension dimension) =&amp;gt;
            ((BlockTableRecord)dimension.DimBlockId.GetObject(OpenMode.ForRead))
            .Cast&amp;lt;ObjectId&amp;gt;()
            .Where(id =&amp;gt; id.ObjectClass.Name == "AcDbMText")
            .Select(id =&amp;gt; (MText)id.GetObject(OpenMode.ForRead))
            .First()
            .Contents;

        private static string GetMeasurementText(Dimension dimension) =&amp;gt;
            (dimension is LineAngularDimension2 || dimension is Point3AngularDimension) ?
            Converter.AngleToString(dimension.Measurement, (AngularUnitFormat)dimension.Dimaunit, dimension.Dimadec) :
            Converter.DistanceToString(dimension.Measurement, (DistanceUnitFormat)dimension.Dimlunit, dimension.Dimdec);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6341473550112w782h540r916" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6341473550112" data-account="6057940548001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6057940548001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6341473550112w782h540r916');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://forums.autodesk.com/t5/video/gallerypage/video-id/6341473550112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 07:33:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-want-to-override-the-dimension-text-with-keeping-the/m-p/12387993#M6700</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2023-11-20T07:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: I want to override the dimension Text with keeping the tolerances as it is</title>
      <link>https://forums.autodesk.com/t5/net-forum/i-want-to-override-the-dimension-text-with-keeping-the/m-p/12388023#M6701</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&lt;BR /&gt;There was Some mistake from my side, I actually attached some other image. I've updated the images please check&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2023 07:36:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/i-want-to-override-the-dimension-text-with-keeping-the/m-p/12388023#M6701</guid>
      <dc:creator>varad.keshatwar</dc:creator>
      <dc:date>2023-11-20T07:36:39Z</dc:date>
    </item>
  </channel>
</rss>

