I recently migrated from Inventor 2024 to 2025. I have a script that returns the total measured lengths of multiple selected edges. This value is represented by a variable called TotalLength that is now returning as a 0 instead of doing the calculation. I'm thinking the Evaluator function on line 57 is no longer working. Can someone tell me what's going on here?
Imports System.Windows.Forms
Sub Main
Dim oSelect As New clsSelect
oSelect.WindowSelect(ThisApplication)
End Sub
Class clsSelect
Private WithEvents oInteractEvents As InteractionEvents
Private WithEvents oSelectEvents As SelectEvents
Private bTooltipEnabled As Boolean
Private ThisApplication As Inventor.Application
Private stillSelecting As Boolean = True
Private TotalLength As Double
Private MinParam As Double
Private MaxParam As Double
Private Length As Double
Public Sub WindowSelect(oApp As Inventor.Application)
ThisApplication = oApp
oInteractEvents = ThisApplication.CommandManager.CreateInteractionEvents
oInteractEvents.InteractionDisabled = False
oSelectEvents = oInteractEvents.SelectEvents
oSelectEvents.AddSelectionFilter(SelectionFilterEnum.kPartEdgeFilter)
oSelectEvents.WindowSelectEnabled = True
bTooltipEnabled = ThisApplication.GeneralOptions.ShowCommandPromptTooltips
ThisApplication.GeneralOptions.ShowCommandPromptTooltips = True
oInteractEvents.StatusBarText = "0 in"
oInteractEvents.Start()
While stillSelecting
ThisApplication.UserInterfaceManager.DoEvents()
End While
End Sub
Private Sub oInteractEvents_OnTerminate() Handles oInteractEvents.OnTerminate
ThisApplication.GeneralOptions.ShowCommandPromptTooltips = bTooltipEnabled
oSelectEvents = Nothing
oInteractEvents = Nothing
stillSelecting = False
End Sub
Private Sub oSelectEvents_OnSelect(ByVal JustSelectedEntities As ObjectsEnumerator, ByVal SelectionDevice As SelectionDeviceEnum, ByVal ModelPosition As Point, ByVal ViewPosition As Point2d, ByVal View As Inventor.View) Handles oSelectEvents.OnSelect
GetLength
End Sub
Private Sub oSelectEvents_OnUnSelect(UnSelectedEntities As ObjectsEnumerator, SelectionDevice As SelectionDeviceEnum, ModelPosition As Point, ViewPosition As Point2d, View As Inventor.View) Handles oSelectEvents.OnUnSelect
GetLength
End Sub
Function GetLength
TotalLength = 0
For Each oObject in oSelectEvents.SelectedEntities
oCurveEval = oObject.Evaluator
oCurveEval.GetParamExtents(MinParam, MaxParam)
oCurveEval.GetLengthAtParam(MinParam, MaxParam, Length)
TotalLength = TotalLength + Length/2.54
Next
oInteractEvents.StatusBarText = TotalLength & " in"
Clipboard.SetText(TotalLength)
End Function
End Class
Solved! Go to Solution.
Solved by WCrihfield. Go to Solution.
Hi @erichter. Maybe try 'declaring' that variable, and its type ahead of time, like:
Dim oCurveEval As Inventor.CurveEvaluator = oObject.Evaluator
It may just be something simple like that...hopefully.
Edit: Unless it sometimes needs to be a Curve2dEvaluator, instead of just the regular CurveEvaluator. I guess it depends on what types of things you have selected.
Wesley Crihfield
(Not an Autodesk Employee)
Can't find what you're looking for? Ask the community or share your knowledge.