<?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: How to find the nearest grid point from location of an MText entity in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-find-the-nearest-grid-point-from-location-of-an-mtext/m-p/6968972#M32180</link>
    <description>&lt;P&gt;I've used the world WIDE&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; web and found this:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2017/ENU/AutoCAD-NET/files/GUID-A588F7CE-C810-49CB-B88A-00B416B9956B-htm.html" target="_blank"&gt;https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2017/ENU/AutoCAD-NET/files/GUID-A588F7CE-C810-49CB-B88A-00B416B9956B-htm.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;What might help you to determine the nearist grid point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not clear to me is based on what point of the MText you want to measure, LL, MC, UR...&lt;/P&gt;
&lt;P&gt;Can you post a picture showing you're requirements?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Mar 2017 20:07:42 GMT</pubDate>
    <dc:creator>SENL1362</dc:creator>
    <dc:date>2017-03-23T20:07:42Z</dc:date>
    <item>
      <title>How to find the nearest grid point from location of an MText entity</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-find-the-nearest-grid-point-from-location-of-an-mtext/m-p/6968648#M32179</link>
      <description>&lt;P&gt;I want to replace a bunch of MText entities with a block.&amp;nbsp; The MText entities are off snap, thus there location property is off snap.&amp;nbsp; I want the replacement block to be inserted on the closest grid snap point to the MText entity being replaced.&lt;BR /&gt;&lt;BR /&gt;I have searched the wild web but cant find anything close to helping with this: Thus I think it must be very easy and I am missing something!&lt;BR /&gt;&lt;BR /&gt;Can anyone point me in the correct direction?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 18:42:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-find-the-nearest-grid-point-from-location-of-an-mtext/m-p/6968648#M32179</guid>
      <dc:creator>oneMSN</dc:creator>
      <dc:date>2017-03-23T18:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the nearest grid point from location of an MText entity</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-find-the-nearest-grid-point-from-location-of-an-mtext/m-p/6968972#M32180</link>
      <description>&lt;P&gt;I've used the world WIDE&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; web and found this:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2017/ENU/AutoCAD-NET/files/GUID-A588F7CE-C810-49CB-B88A-00B416B9956B-htm.html" target="_blank"&gt;https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2017/ENU/AutoCAD-NET/files/GUID-A588F7CE-C810-49CB-B88A-00B416B9956B-htm.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;What might help you to determine the nearist grid point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not clear to me is based on what point of the MText you want to measure, LL, MC, UR...&lt;/P&gt;
&lt;P&gt;Can you post a picture showing you're requirements?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 20:07:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-find-the-nearest-grid-point-from-location-of-an-mtext/m-p/6968972#M32180</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2017-03-23T20:07:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the nearest grid point from location of an MText entity</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-find-the-nearest-grid-point-from-location-of-an-mtext/m-p/6969012#M32181</link>
      <description>Thanks I get how to adjust and set the grid but that's not what i want.&lt;BR /&gt;&lt;BR /&gt;Let's say my grid and snap settings are 3x 3y (no interest in z here).&lt;BR /&gt;&lt;BR /&gt;My MText insertion point might be 3.1234, 3.4321. I wondered if there was a built in method to get the nearest snap position which would be 3,3 .&lt;BR /&gt;&lt;BR /&gt;Now I have a method of rolling my own function to do this i think, but not written it yet or tested it. Before I did this I figured that this must be a common requirement and perhaps the Api had a helper function available to calculate the nearest snap point.&lt;BR /&gt;&lt;BR /&gt;Which is what my question tries to ask.</description>
      <pubDate>Thu, 23 Mar 2017 20:20:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-find-the-nearest-grid-point-from-location-of-an-mtext/m-p/6969012#M32181</guid>
      <dc:creator>oneMSN</dc:creator>
      <dc:date>2017-03-23T20:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the nearest grid point from location of an MText entity</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-find-the-nearest-grid-point-from-location-of-an-mtext/m-p/6969892#M32182</link>
      <description>&lt;P&gt;I don't know of any API that can do what you asked for.&lt;BR /&gt;But youre problem is more a rounding issue, i.e. pMT=SnapBase+n*(dX, dY)&lt;BR /&gt;(assuming the SnapAngle=0)&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2017 07:22:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-find-the-nearest-grid-point-from-location-of-an-mtext/m-p/6969892#M32182</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2017-03-24T07:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the nearest grid point from location of an MText entity</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-find-the-nearest-grid-point-from-location-of-an-mtext/m-p/6970285#M32183</link>
      <description>&lt;P&gt;Cool, Ill build my own extension method for the Point#d class.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2017 11:07:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-find-the-nearest-grid-point-from-location-of-an-mtext/m-p/6970285#M32183</guid>
      <dc:creator>oneMSN</dc:creator>
      <dc:date>2017-03-24T11:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the nearest grid point from location of an MText entity</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-find-the-nearest-grid-point-from-location-of-an-mtext/m-p/6970471#M32184</link>
      <description>&lt;P&gt;the exact same question was asked a while ago;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://forums.autodesk.com/t5/net/how-to-automatically-create-a-mtext-spaced-every-100mm/m-p/5667670#M44870" target="_blank"&gt;https://forums.autodesk.com/t5/net/how-to-automatically-create-a-mtext-spaced-every-100mm/m-p/5667670#M44870&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;to quote my self:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I understood you correctly... I dont think it should be a problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) prompt for first point3d(2d), prompt for 2nd point3d(2d)&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1***) you may also prompt for distance that you'd like them to be created at... so it's not always 100...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;2)&amp;nbsp;spwn new text while their cordinates are &amp;lt; than 2nd point.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="http://through-the-interface.typepad.com/through_the_interface/2010/06/creating-an-autocad-mtext-object-containing-different-colours-using-net.html" target="_blank" rel="nofollow noopener noreferrer"&gt;http://through-the-interface.typepad.com/through_t&lt;WBR /&gt;he_interface/2010/06/creating-an-autocad-mtext-obj&lt;WBR /&gt;...&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;as for the conditioning... its basic programing concept.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;should look like this;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;newpoint=startpoint;&lt;/P&gt;
&lt;P&gt;while(newpoint+100&amp;lt;endpoint)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;newpoint=lastpoint+100;&lt;/P&gt;
&lt;P&gt;creteMtext(newpoint);&lt;/P&gt;
&lt;P&gt;lastpoint=newpoint;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;P.S. an exception should be made... in case the 2st point&amp;nbsp;coordinate value is&amp;nbsp;"smaller" than the 1st. one... to counter it... a "distance" value should be used to spwn new text.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2017 12:15:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-find-the-nearest-grid-point-from-location-of-an-mtext/m-p/6970471#M32184</guid>
      <dc:creator>5thSth</dc:creator>
      <dc:date>2017-03-24T12:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the nearest grid point from location of an MText entity</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-find-the-nearest-grid-point-from-location-of-an-mtext/m-p/6974104#M32185</link>
      <description>&lt;P&gt;I solved this with an Extension method.&amp;nbsp; Just in case anyone else needs this here's the rough cut code I created.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;public static Point2d GetNearestSnapPoint(this Point2d point)
        {
            Point2d snapPoint;

            double snapPointX, snapPointY;

            CalculateSnapCoordinates(point.X, point.Y, out snapPointX, out snapPointY);

            snapPoint = new Point2d(snapPointX, snapPointY);

            return snapPoint;
        }

private static void CalculateSnapCoordinates(
            double originalX, double originalY, out double snapPointX, out double snapPointY)
        {
            var snapIncrements = AutoCADUtilities.GetSnapIncrements();

            double devisorX = originalX / snapIncrements.X;
            double devisorY = originalY / snapIncrements.Y;

            double xMod = Math.Truncate(devisorX);
            double yMod = Math.Truncate(devisorY);

            var addXSnapPoint = Math.Abs(devisorX % 1) &amp;gt; 0.5;
            var addYSnapPoint = Math.Abs(devisorY % 1) &amp;gt; 0.5;


            snapPointX = xMod * snapIncrements.X;
            snapPointY = yMod * snapIncrements.Y;
            if (addXSnapPoint)
                snapPointX += snapIncrements.X;

            if (addYSnapPoint)
                snapPointY += snapIncrements.Y;
        }&lt;/PRE&gt;</description>
      <pubDate>Sun, 26 Mar 2017 18:39:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-find-the-nearest-grid-point-from-location-of-an-mtext/m-p/6974104#M32185</guid>
      <dc:creator>oneMSN</dc:creator>
      <dc:date>2017-03-26T18:39:16Z</dc:date>
    </item>
  </channel>
</rss>

