Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
erichter
224 Views, 2 Replies

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

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

 

2 REPLIES 2
Message 2 of 3
WCrihfield
in reply to: erichter

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
in reply to: WCrihfield

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report