Message 1 of 18
Remove or Replace Event Listener after iLogic rule completes runtime

Not applicable
12-08-2017
11:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'll admit I'm new to events. The iLogic code below works as expected (gives name of constraint or Joint after it is created).
Option Explicit Sub Main Dim evtListener As New MateListener(ThisServer, Parameter) End Sub Public Class MateListener Private WithEvents m_AsmEvts As Inventor.AssemblyEvents = Nothing Private Parameter As Object Sub New(invServer As InventorServer, Parameter As Object) m_AsmEvts = invServer.AssemblyEvents Me.Parameter = Parameter End Sub Private Sub m_AsmEvts_OnNewRelation(ByVal DocumentObject As Inventor._AssemblyDocument, ByVal Relationship As Object, ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum) Handles m_AsmEvts.OnNewRelationship If BeforeOrAfter = Inventor.EventTimingEnum.kAfter Then MsgBox("new relationship:" & vbTab & Relationship.Name) End If End Sub End Class
My problem is a new event listener is created each time I run the rule. How to I delete or overwrite the original listener? Can I delete all OnNewRelationship listeners?
The only way to remove the listener is to close inventor. I need to add a lot more code to this so this makes troubleshooting impossible.
I have read about using RemoveHandler but after the rule has run I don't have the object any more. Is there a list/collection of events?
RemoveHandler m_AppEvents.OnActivateDocument, AddressOf ApplicationEvents_OnActivateDocument
http://modthemachine.typepad.com/my_weblog/2013/07/inventor-events-using-net-3-examples.html