<?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 Polyline.GetClosestPointTo giving wrong result in AutoCAD Map 3D Developer Forum</title>
    <link>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/polyline-getclosestpointto-giving-wrong-result/m-p/5524240#M1447</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using AutoCAD 2012 &amp;amp; VS 2010.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have polyline&amp;nbsp;feature with coordinates 1. X=11992.9202, Y=2035.9537. 2. X= 12452, Y=2039.8486. 3. X=13280, Y=2046.8707&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have written code to select the polyline and also written to select nea point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;selected nearest point is 'X=12838.076824 and Y = 2043.121578'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.When i try to use get param point, getting exception 'eInvalidInput'. expecting closest point.&lt;/P&gt;&lt;P&gt;2. Wheni try to use get closest point then i am getting resltent point foraway i.e X=507534.76892 and Y=6159118.6698.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So i am not getting the proper result. i dont know where the issues. stuck with issue long time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any support much appriciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Dayalan&lt;/P&gt;</description>
    <pubDate>Sun, 01 Mar 2015 09:11:34 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2015-03-01T09:11:34Z</dc:date>
    <item>
      <title>Polyline.GetClosestPointTo giving wrong result</title>
      <link>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/polyline-getclosestpointto-giving-wrong-result/m-p/5524240#M1447</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using AutoCAD 2012 &amp;amp; VS 2010.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have polyline&amp;nbsp;feature with coordinates 1. X=11992.9202, Y=2035.9537. 2. X= 12452, Y=2039.8486. 3. X=13280, Y=2046.8707&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have written code to select the polyline and also written to select nea point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;selected nearest point is 'X=12838.076824 and Y = 2043.121578'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.When i try to use get param point, getting exception 'eInvalidInput'. expecting closest point.&lt;/P&gt;&lt;P&gt;2. Wheni try to use get closest point then i am getting resltent point foraway i.e X=507534.76892 and Y=6159118.6698.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So i am not getting the proper result. i dont know where the issues. stuck with issue long time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any support much appriciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Dayalan&lt;/P&gt;</description>
      <pubDate>Sun, 01 Mar 2015 09:11:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/polyline-getclosestpointto-giving-wrong-result/m-p/5524240#M1447</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-03-01T09:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: Polyline.GetClosestPointTo giving wrong result</title>
      <link>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/polyline-getclosestpointto-giving-wrong-result/m-p/5524242#M1448</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the values you show seems strange, so 2 ideas for now:&lt;/P&gt;
&lt;P&gt;a) are you sure that you don't have a UCS (other than WCS) active?&lt;/P&gt;
&lt;P&gt;b) if yes please upload this drawing + the code-snippet of a sample, that we see the exact code you are using and this can be reproduced by others&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT color="#000080"&gt;&amp;gt;&amp;gt; When i try to use get param point, getting exception 'eInvalidInput'. expecting closest point.&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;I guess you mean the function &lt;STRONG&gt;&lt;FONT color="#000080"&gt;GetParameterAtPoint&lt;/FONT&gt;&lt;/STRONG&gt;? ... there you need to ask for a point that is exactly on that curve. By default I use first the &lt;STRONG&gt;&lt;FONT color="#000080"&gt;GetClosestPointTo&lt;/FONT&gt; &lt;/STRONG&gt;and the resulting point I forward to the &lt;STRONG&gt;&lt;FONT color="#000080"&gt;GetParameterAtPoint&lt;/FONT&gt; &lt;/STRONG&gt;function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- alfred -&lt;/P&gt;</description>
      <pubDate>Sun, 01 Mar 2015 09:32:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/polyline-getclosestpointto-giving-wrong-result/m-p/5524242#M1448</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2015-03-01T09:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: Polyline.GetClosestPointTo giving wrong result</title>
      <link>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/polyline-getclosestpointto-giving-wrong-result/m-p/5525244#M1449</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your mail.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here i attached drawing file and code as zip.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please review and suggest.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dayalan&lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2015 16:42:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/polyline-getclosestpointto-giving-wrong-result/m-p/5525244#M1449</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-03-02T16:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: Polyline.GetClosestPointTo giving wrong result</title>
      <link>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/polyline-getclosestpointto-giving-wrong-result/m-p/5525294#M1450</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;first I get an exception as the polyline you used get's accessed outside the active transaction. That is not safe.&lt;/P&gt;
&lt;P&gt;I then converted part of the code to create a transaction before I use the polyline.GetClosestPointTo and then polyline.GetParameterAtPoint and can't see any differences between the values I get reported from VisualStudio and the ones from AutoCAD directly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So either the issue is that you close/dispose your transaction before you try to get properties from it (or calculations like polyline.Get...) or I'm doing anything in another way than you do. I see that I have to start command "11", but what points I should show or what entity I have to select then ... don't know that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code I created to get the point1 and point2 converted to parameter is that (in VB.NET, you can convert it using public converters in the www).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;      Dim tTrAct As Transaction = Nothing
      Try
         tTrAct = centerLineEntity.Database.TransactionManager.StartOpenCloseTransaction
         Dim tCurve As Curve = TryCast(tTrAct.GetObject(centerLineEntity.ObjectId, OpenMode.ForRead), Curve)
         If tCurve IsNot Nothing Then
            'get param for first point
            Dim pintNea As Point3d = tCurve.GetClosestPointTo(startPoint, False)
            Dim paramStart As Double = tCurve.GetParameterAtPoint(pintNea)
            'get param for second point
            Dim pintNea2 As Point3d = tCurve.GetClosestPointTo(endPoint, False)
            Dim paramEnd As Double = tCurve.GetParameterAtPoint(pintNea2)
         End If
      Catch generatedExceptionName As System.Exception
         'TODO exception handling
      Finally
         If tTrAct IsNot Nothing Then tTrAct.Dispose() : tTrAct = Nothing
      End Try
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- alfred -&lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2015 17:15:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/polyline-getclosestpointto-giving-wrong-result/m-p/5525294#M1450</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2015-03-02T17:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: Polyline.GetClosestPointTo giving wrong result</title>
      <link>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/polyline-getclosestpointto-giving-wrong-result/m-p/5525641#M1451</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand and resolved the issue. My drawing is having some custom UCS. I set to World and now my custom code is working fine as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your support&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Dayalan&lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2015 21:01:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/autocad-map-3d-developer-forum/polyline-getclosestpointto-giving-wrong-result/m-p/5525641#M1451</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-03-02T21:01:56Z</dc:date>
    </item>
  </channel>
</rss>

