Script that works in Inventor 2024 does not function in Inventor 2025

Script that works in Inventor 2024 does not function in Inventor 2025

erichter
Advocate Advocate
384 Views
2 Replies
Message 1 of 3

Script that works in Inventor 2024 does not function in Inventor 2025

erichter
Advocate
Advocate

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

 

0 Likes
Accepted solutions (1)
385 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor
Accepted 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

EESignature

(Not an Autodesk Employee)

Message 3 of 3

erichter
Advocate
Advocate

Thanks, that worked. Curious why it's different in 2025 though.

0 Likes