Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WCrihfield
in reply to: josh.nieman

Hi @josh.nieman.  Good question.  I have never thought about making a list like that, or why I would want a list like that, but it does sound interesting.  I can think of several scenarios where we have to 'enter an edit mode' of something, in order to edit them.  In every one of those situations, there will be a change to what 'object' is the active edit object.  And when exiting that 'edit mode' it would change again.  I will post a couple code examples that could be used for exploration purposes.

This first example is the most basic, and could be used as an external rule, and place a button for it in the ribbon.  Click it any time you want to, and it will write the Type of the currently active edit object to the iLogic Log window, for review.  That could also be changed to something like a MsgBox or MessageBox.Show, or similar.

Dim AEO As Object = ThisApplication.ActiveEditObject
Logger.Info("ActiveEditObject Type = " & TypeName(AEO))

However, there is actually an Inventor API event for that type of situation.

ApplicationEvents.OnNewEditObject Event 

And below is a relatively basic iLogic rule which includes an example of initializing that event handler.  However, once launched, it will continue running in the background of Inventor until you quit or restart Inventor, because I have not programmed in a 'back-door' way to eliminate it when something else happens later.

Sub Main
	InvApp = ThisApplication
	AppEvents = InvApp.ApplicationEvents
	AddHandler AppEvents.OnNewEditObject, AddressOf AppEvents_OnNewEditObject
End Sub

Private InvApp As Inventor.Application
Private AppEvents As Inventor.ApplicationEvents

Sub AppEvents_OnNewEditObject(EditObject As Object, BeforeOrAfter As EventTimingEnum, Context As NameValueMap, ByRef HandlingCode As HandlingCodeEnum)
	If BeforeOrAfter = EventTimingEnum.kAfter Then
		Logger.Info("EditObject Type = " & TypeName(EditObject))
		If Context IsNot Nothing AndAlso Context.Count > 0 Then
			Dim oActiveDoc As Inventor.Document = Nothing
			Dim oActiveEditObj As Object = Nothing
			For i As Integer = 1 To Context.Count
				Dim sName As String = Context.Name(i)
				Dim oValue As Object = Context.Value(sName)
				If sName = "ActiveDocument" Then
					oActiveDoc = oValue
					Logger.Info("ActiveDocument = " & oActiveDoc.FullDocumentName)
				ElseIf sName =  "ActiveEditObject" Then
					oActiveEditObj = oValue
					Logger.Info("ActiveEditObject Type = " & TypeName(oActiveEditObj))
				End If
			Next
		End If
	End If
End Sub

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) :thumbs_up:.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)