Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Request: List of all types that can be returned via "InventorApplication.ActiveEditObject"

josh.nieman
Advocate

Request: List of all types that can be returned via "InventorApplication.ActiveEditObject"

josh.nieman
Advocate
Advocate

It may just be that my google-fu is weak this Monday morning, but I thought I recalled seeing a list of all object types that can be accessible via "ActiveEditObject"

(note: I do not mean ActiveEditDocument)

 

I thought I came across it somewhere, but I cannot find it, if I ever did.
I just want to make myself an easy helper function to get "ActiveEditObject" as well as automatically returning what it's TYPE is, in some manner.

 

----> Has anyone found or made a list of all ActiveEditObject TYPE possibilities that you'd be willing to share?

 

Alternatively, is there even a way one could efficiently even collect this on their own?

 

I could list all I could THINK of but surely I'd miss some or many.

0 Likes
Reply
226 Views
4 Replies
Replies (4)

josh.nieman
Advocate
Advocate

As a follow-up, I did find what I believe is the list I recalled.
It's within the Remarks on this help page for the OnNewEditObject ApplicationEventhttps://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=ApplicationEvents_OnNewEditObject 

Valid objects for edit objects are documents, 2d and 3d sketches, and drawing sheets.

But clearly this list isn't complete, but just supplying examples. I know there are additional valid objects such as FlatPattern.

I just don't know what /all/ the ActiveEditObject can encompass. Does it return "PartFeature" (or specific subtype of) if a Part model feature is being edited? etc, etc, etc.

0 Likes

WCrihfield
Mentor
Mentor

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)

josh.nieman
Advocate
Advocate

I think you and I came to a pretty similar conclusion.

 

There's many types that can be edited in-place but not really any convenient list anywhere. So far my only idea is like you recommended; add an event handler that'll log each ActiveEditObject type, launch Inventor, and "in-place edit" as many things as I could think of and start with that list, using the OnNewEditObject (as linked in the OP) event handler in my add-in.

 

Ah well. If no one supplies a good list and I end up compiling my own, I'll follow up and share. Otherwise I may just add the specific object Types I care about as-needed and not worry about it.

WCrihfield
Mentor
Mentor

Likely the 3 least expected are while working on a weldment type assembly, because there are so few code examples of doing those types of things here in this forum.  Generally, when you have a weldment type assembly open, but are are not yet in any specific 'edit mode', you just get something very generic, and useless like "_DocumentClass".  But then there are the "Welds", Machining", and "Preparations".  Each of those sub environments can actually be activated by code also, when starting from the WeldmentComponentDefinition.

Welds.Edit 

Machining.Edit 

Preparations.Edit 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)