<?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: SketchEntity Evaluators appear to be severly broken in VB in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/sketchentity-evaluators-appear-to-be-severly-broken-in-vb/m-p/10681058#M129905</link>
    <description>&lt;P&gt;This is little bit modified version of your code. It works well.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I don't check type of entity and I directly try to get Evaluator from sketchEntity (Using LateBinding in VB.NET).&lt;/LI&gt;&lt;LI&gt;I change mid point calculation.&lt;/LI&gt;&lt;LI&gt;I change building of final message&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Sub Main
	Dim part As PartDocument = ThisDoc.Document
	Dim sk As PlanarSketch = part.ComponentDefinition.Sketches("Test Sketch")
	
	For Each sketchEntity As SketchEntity In sk.SketchEntities
		Dim evaluator As Curve2dEvaluator = GetEvaluator(SketchEntity)
		If evaluator Is Nothing Then Continue For

		Dim periodicity As Double() = {}
		Dim isSingular As Boolean
		Dim unboundedParameter As Boolean
		evaluator.GetParamAnomaly(periodicity, isSingular, unboundedParameter)

		Dim endPoint As Double() = {}
		Dim startPoint As Double() = {}
		evaluator.GetEndPoints(startPoint, endPoint)

		Dim minParam As Double
		Dim maxParam As Double
		Dim midParam As Double
		Dim midPoint As Double() = {}

		evaluator.GetParamExtents(minParam, maxParam)
		midParam = minParam + (maxParam - minParam) / 2
		evaluator.GetPointAtParam(New Double() {midParam }, midPoint)

		Dim msg As String = String.Format( _
"Curve Type: {0}" &amp;amp; vbCrLf &amp;amp; _
"Start Point: [{1:N3},{2:N3}]" &amp;amp; vbCrLf &amp;amp; _
"End point: [{3:N3}, {4:N3}]" &amp;amp; vbCrLf &amp;amp; _
"Mid Point: [{5:N3}, {6:N3}]" &amp;amp; vbCrLf &amp;amp; _
"Param anomaly:" &amp;amp; vbCrLf &amp;amp; _
" - periodicity: [{7:N3}, {8:N3}]" &amp;amp; vbCrLf &amp;amp; _
" - Is sinhgular: {9}" &amp;amp; vbCrLf &amp;amp; _
" - Unbounded parameter: {10}",
		SketchEntity.Type,
		startPoint(0), startPoint(1),
		endPoint(0), endPoint(1),
		midPoint(0), midPoint(1),
		periodicity(0), periodicity(1),
		isSingular,
		unboundedParameter
		)

		MsgBox(msg, Title := "Curve Info")
	Next


End Sub

Function GetEvaluator(sketchEntity As SketchEntity) As Curve2dEvaluator
	Try
		Return sketchEntity.Geometry.Evaluator
	Catch
		Return Nothing
	End Try
End Function&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Oct 2021 17:46:25 GMT</pubDate>
    <dc:creator>Michael.Navara</dc:creator>
    <dc:date>2021-10-11T17:46:25Z</dc:date>
    <item>
      <title>SketchEntity Evaluators appear to be severly broken in VB</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/sketchentity-evaluators-appear-to-be-severly-broken-in-vb/m-p/10680032#M129876</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the attached file contains a reduced example.&lt;/P&gt;&lt;P&gt;A sketch with some random geometry:&lt;/P&gt;&lt;P&gt;An arc, a line and a bisected spline.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It also contains one rule:&lt;/P&gt;&lt;P&gt;For each entity, the parameter range is determined by Geometry.Evaluator.GetParamExtents(uMin, uMax). Then, three points are calculated: one at the start, one at the end, one in the middle, using Geometry.Evaluator.GetPointAtParam.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A message box displays the results for each entity.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Expected behavior would be for the output to match the apparent start point in the sketch.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Actual behavior is that lines are evaluated as expected, splines are hit-and-miss and arcs are completely broken. Others not tested.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Current workaround is to write my own evaluator based on the known geometry properties for the arc case, and for the spline case to pray.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not interested in these particular points. I need the evaluator to function generally.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please advise/fix&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Samuel&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 09:56:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/sketchentity-evaluators-appear-to-be-severly-broken-in-vb/m-p/10680032#M129876</guid>
      <dc:creator>samuel.sudhofKWJYQ</dc:creator>
      <dc:date>2021-10-11T09:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: SketchEntity Evaluators appear to be severly broken in VB</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/sketchentity-evaluators-appear-to-be-severly-broken-in-vb/m-p/10681058#M129905</link>
      <description>&lt;P&gt;This is little bit modified version of your code. It works well.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I don't check type of entity and I directly try to get Evaluator from sketchEntity (Using LateBinding in VB.NET).&lt;/LI&gt;&lt;LI&gt;I change mid point calculation.&lt;/LI&gt;&lt;LI&gt;I change building of final message&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Sub Main
	Dim part As PartDocument = ThisDoc.Document
	Dim sk As PlanarSketch = part.ComponentDefinition.Sketches("Test Sketch")
	
	For Each sketchEntity As SketchEntity In sk.SketchEntities
		Dim evaluator As Curve2dEvaluator = GetEvaluator(SketchEntity)
		If evaluator Is Nothing Then Continue For

		Dim periodicity As Double() = {}
		Dim isSingular As Boolean
		Dim unboundedParameter As Boolean
		evaluator.GetParamAnomaly(periodicity, isSingular, unboundedParameter)

		Dim endPoint As Double() = {}
		Dim startPoint As Double() = {}
		evaluator.GetEndPoints(startPoint, endPoint)

		Dim minParam As Double
		Dim maxParam As Double
		Dim midParam As Double
		Dim midPoint As Double() = {}

		evaluator.GetParamExtents(minParam, maxParam)
		midParam = minParam + (maxParam - minParam) / 2
		evaluator.GetPointAtParam(New Double() {midParam }, midPoint)

		Dim msg As String = String.Format( _
"Curve Type: {0}" &amp;amp; vbCrLf &amp;amp; _
"Start Point: [{1:N3},{2:N3}]" &amp;amp; vbCrLf &amp;amp; _
"End point: [{3:N3}, {4:N3}]" &amp;amp; vbCrLf &amp;amp; _
"Mid Point: [{5:N3}, {6:N3}]" &amp;amp; vbCrLf &amp;amp; _
"Param anomaly:" &amp;amp; vbCrLf &amp;amp; _
" - periodicity: [{7:N3}, {8:N3}]" &amp;amp; vbCrLf &amp;amp; _
" - Is sinhgular: {9}" &amp;amp; vbCrLf &amp;amp; _
" - Unbounded parameter: {10}",
		SketchEntity.Type,
		startPoint(0), startPoint(1),
		endPoint(0), endPoint(1),
		midPoint(0), midPoint(1),
		periodicity(0), periodicity(1),
		isSingular,
		unboundedParameter
		)

		MsgBox(msg, Title := "Curve Info")
	Next


End Sub

Function GetEvaluator(sketchEntity As SketchEntity) As Curve2dEvaluator
	Try
		Return sketchEntity.Geometry.Evaluator
	Catch
		Return Nothing
	End Try
End Function&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Oct 2021 17:46:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/sketchentity-evaluators-appear-to-be-severly-broken-in-vb/m-p/10681058#M129905</guid>
      <dc:creator>Michael.Navara</dc:creator>
      <dc:date>2021-10-11T17:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: SketchEntity Evaluators appear to be severly broken in VB</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/sketchentity-evaluators-appear-to-be-severly-broken-in-vb/m-p/10682051#M129927</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for taking the time to help me with my problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Beside the cosmetic changes, about which I think reasonable minds may differ, you made a change to the way that that the parameter variable is allocated. Whereas I allocated the memory at the top of the function, you did so in line with the function call.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Works)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;evaluator.GetPointAtParam(New Double() {midParam }, midPoint)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;vs (Works unreliably)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Dim u(1) as Double
u(0)=midParam

evaluator.GetPointAtParam(u, midPoint)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This seems to be a functioning workaround. Thank you for providing this solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone from Autodesk is around, I would like to know if this is indeed bugged, or if I have somehow missed an important point about memory allocation in VBA.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 05:10:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/sketchentity-evaluators-appear-to-be-severly-broken-in-vb/m-p/10682051#M129927</guid>
      <dc:creator>samuel.sudhofKWJYQ</dc:creator>
      <dc:date>2021-10-12T05:10:59Z</dc:date>
    </item>
  </channel>
</rss>

