<?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: Exception raised on evaluator.getPointsAtParameters from parameters given by in Fusion API and Scripts Forum</title>
    <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exception-raised-on-evaluator-getpointsatparameters-from/m-p/6531950#M19414</link>
    <description>&lt;P&gt;I agree with your argument. However, getPointsAtParameters contradicts it.&lt;/P&gt;&lt;P&gt;Let me explain it better:&lt;/P&gt;&lt;P&gt;&amp;nbsp; getParametersAtPoint(pt) returns parameters beyond the curve, as you explained.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the same argument as you did, why getPointsAtParameters validates the parameters if its inverse function allows to return parameters beyond its curve extents? That sounds like contradictory. I would love to have both functions returning parameters beyond the curve. That's the whole point about parametrized curves, right?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Aug 2016 18:34:40 GMT</pubDate>
    <dc:creator>gscotti</dc:creator>
    <dc:date>2016-08-30T18:34:40Z</dc:date>
    <item>
      <title>Exception raised on evaluator.getPointsAtParameters from parameters given by ev.</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exception-raised-on-evaluator-getpointsatparameters-from/m-p/6530310#M19410</link>
      <description>&lt;P&gt;This is the failing code:&lt;/P&gt;&lt;PRE&gt;           ev = curve.geometry.evaluator
            ret, params = ev.getParametersAtPoints(points)
            if not ret:
                raise AttributeError('invalid points in getParametersAtPoints')

            print(params,curve.geometry)
            ret, pts = ev.getPointsAtParameters(params)
            if not ret:
                raise AttributeError('invalid points in getPointsAtParameters')&lt;/PRE&gt;&lt;P&gt;I've attached the model I'm trying it with. Sketch1 works (circles) but Sketch2 fails (rectangles.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 03:59:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exception-raised-on-evaluator-getpointsatparameters-from/m-p/6530310#M19410</guid>
      <dc:creator>gscotti</dc:creator>
      <dc:date>2016-08-30T03:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: Exception raised on evaluator.getPointsAtParameters from parameters given by</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exception-raised-on-evaluator-getpointsatparameters-from/m-p/6531914#M19411</link>
      <description>&lt;P&gt;The API exposes some underlying math and geometry tools and we get whatever their native behavior is.&amp;nbsp; In this case it appears that the getParameterAtPoints ignores the limits of the curve and returns parameters as if the curve was not bounded.&amp;nbsp; For example, it treats a line as infinite length and an arc as a circle.&amp;nbsp; But the getPointAtParameter expects the input parameter to be within the bounded portion of the curve and that's why it's failing.&amp;nbsp; I modified your function so it now checks if the parameter is within the bounded range and if not, adjusts it to the closest end.&amp;nbsp; I tried on various shapes and it seems to work now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;    def findClosestPoints(self, points):
        n = len(points)
        ptsOnCurve = [{} for i in range(n)]
        for curve in self.curves:
            ev = adsk.core.CurveEvaluator3D.cast(curve.geometry.evaluator)
            &lt;STRONG&gt;ret, minExtent, maxExtent = ev.getParameterExtents()&lt;/STRONG&gt;

            ret, params = ev.getParametersAtPoints(points)
            if not ret:
                raise AttributeError('invalid points in getParametersAtPoints')

            &lt;STRONG&gt;newParams = []
            for param in params:
                if param &amp;lt; minExtent:
                    newParams.append(minExtent)
                elif param &amp;gt; maxExtent:
                    newParams.append(maxExtent)
                else:
                    newParams.append(param)
&lt;/STRONG&gt;
            print(params,curve.geometry)
            if len(newParams) &amp;gt; 0:
                ret, pts = ev.getPointsAtParameters(&lt;STRONG&gt;newParams&lt;/STRONG&gt;)
                if not ret:
                    raise AttributeError('invalid points in getPointsAtParameters')
    
                for i in range(n):
                    d = points[i].distanceTo(pts[i])
                    ptsOnCurve[i][d] = (pts[i],curve)

        # query min points
        output = []
        if len(ptsOnCurve[0]) &amp;gt; 0:
            for i in range(n):
                dmin = min(ptsOnCurve[i])
                pt,curve = ptsOnCurve[i][dmin]
                output.append((pt,curve))

        return output&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Aug 2016 18:10:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exception-raised-on-evaluator-getpointsatparameters-from/m-p/6531914#M19411</guid>
      <dc:creator>ekinsb</dc:creator>
      <dc:date>2016-08-30T18:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: Exception raised on evaluator.getPointsAtParameters from parameters given by</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exception-raised-on-evaluator-getpointsatparameters-from/m-p/6531927#M19412</link>
      <description>&lt;P&gt;I ended up doing the same as you did. However, you are expected to get valid data from the API functions, don't you think?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 18:14:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exception-raised-on-evaluator-getpointsatparameters-from/m-p/6531927#M19412</guid>
      <dc:creator>gscotti</dc:creator>
      <dc:date>2016-08-30T18:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: Exception raised on evaluator.getPointsAtParameters from parameters given by</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exception-raised-on-evaluator-getpointsatparameters-from/m-p/6531940#M19413</link>
      <description>&lt;P&gt;I think this is a case where "valid" is left up to some interpretation so returning a parameter on the boundless curve can be considered valid and it could be used to determine if the input point is one the curve or outside. &amp;nbsp;Whereas if we were to adjust the parameters to the bounded portion you couldn't do that. &amp;nbsp;But returning parameters within the bounded extents could also be considered "valid". &amp;nbsp;Regardless, of what we consider to be "correct", we'll leave the behavior the way it is in case people have taken advantage of the current behavior and we don't want to break them. &amp;nbsp;I will make a note to add some additional information to the documentation about the behavior though.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 18:20:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exception-raised-on-evaluator-getpointsatparameters-from/m-p/6531940#M19413</guid>
      <dc:creator>ekinsb</dc:creator>
      <dc:date>2016-08-30T18:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: Exception raised on evaluator.getPointsAtParameters from parameters given by</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exception-raised-on-evaluator-getpointsatparameters-from/m-p/6531950#M19414</link>
      <description>&lt;P&gt;I agree with your argument. However, getPointsAtParameters contradicts it.&lt;/P&gt;&lt;P&gt;Let me explain it better:&lt;/P&gt;&lt;P&gt;&amp;nbsp; getParametersAtPoint(pt) returns parameters beyond the curve, as you explained.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the same argument as you did, why getPointsAtParameters validates the parameters if its inverse function allows to return parameters beyond its curve extents? That sounds like contradictory. I would love to have both functions returning parameters beyond the curve. That's the whole point about parametrized curves, right?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 18:34:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exception-raised-on-evaluator-getpointsatparameters-from/m-p/6531950#M19414</guid>
      <dc:creator>gscotti</dc:creator>
      <dc:date>2016-08-30T18:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: Exception raised on evaluator.getPointsAtParameters from parameters given by</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exception-raised-on-evaluator-getpointsatparameters-from/m-p/6531964#M19415</link>
      <description>And I hope you don't change the behavior of getParametersAtPoints, because I've been using it to get closest point at curves, for the lack of a better function. Which is not exactly the way you describe its purpose is. Is it correct to say "..could be used to determine if the input point is beyond the curve or not." Because is 'on' or 'outside' the curve is a open to interpretations.</description>
      <pubDate>Tue, 30 Aug 2016 18:27:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exception-raised-on-evaluator-getpointsatparameters-from/m-p/6531964#M19415</guid>
      <dc:creator>gscotti</dc:creator>
      <dc:date>2016-08-30T18:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: Exception raised on evaluator.getPointsAtParameters from parameters given by</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exception-raised-on-evaluator-getpointsatparameters-from/m-p/6531995#M19416</link>
      <description>&lt;P&gt;I agree that there is some contradiction in the behavior. &amp;nbsp;As I said, the API is using a general geometry and math library (actually AcGe which comes from AutoCAD) and we get that library's&amp;nbsp;native behavior. &amp;nbsp;However, I just looked at the API source code and we're adding an extra check in getPointsAtParameters to validate if the input parameter is on the curve and if it's not it fails with the "invalid argument parameters"&amp;nbsp;error. &amp;nbsp;So &lt;SPAN&gt;g&lt;/SPAN&gt;&lt;SPAN&gt;etPointsAtParameters &lt;/SPAN&gt; cares about the bounds and getParametersAtPoint doesn't. &amp;nbsp;But I would be hesitant to change the behavior at this point but we should document it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And yes, saying the point is "beyond the curve or not" is probably a better way to say it. &amp;nbsp;Anytime the point is off the curve though there could be some unexpected results for some cases. &amp;nbsp;For a line or arc it's simple because a boundless arc is always a circle and a boundless line is known. &amp;nbsp;However a spline can't necessarily be extended to infinity and can curve in unexpected ways when it is extended. &amp;nbsp;And it's possible there could be multiple correct answers. &amp;nbsp;For example, what parameter should be returned if you input the center point of a circle for the circle? &amp;nbsp;I know these are not typical cases but I'm just trying to say that it's best to use points that lie very near the curve to get the best results.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 18:38:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exception-raised-on-evaluator-getpointsatparameters-from/m-p/6531995#M19416</guid>
      <dc:creator>ekinsb</dc:creator>
      <dc:date>2016-08-30T18:38:23Z</dc:date>
    </item>
    <item>
      <title>Re: Exception raised on evaluator.getPointsAtParameters from parameters given by</title>
      <link>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exception-raised-on-evaluator-getpointsatparameters-from/m-p/6532015#M19417</link>
      <description>&lt;P&gt;Understood. I believe the whole point is that getParametersAtPoints should not return any parameter outside its parameters limits. From parametric math perspective, that's wrong, because the returned value is not within the curve's domain. Perhaps the whole point is to think that a bounded line is an infinite line, which&amp;nbsp;in this case it is&amp;nbsp;not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To answer your question: I expect to get any parameter from the parametric circle if I give origin as reference point. Same thing happens if set any point inside the circle: you have two possible points, and&amp;nbsp;whichever is returned is what I would expect as a valid answer. That's actually a good test case for the API. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 18:54:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/exception-raised-on-evaluator-getpointsatparameters-from/m-p/6532015#M19417</guid>
      <dc:creator>gscotti</dc:creator>
      <dc:date>2016-08-30T18:54:29Z</dc:date>
    </item>
  </channel>
</rss>

