Assembly Events for deleting WorkPoint / WorkPlane

Assembly Events for deleting WorkPoint / WorkPlane

FINET_Laurent
Advisor Advisor
146 Views
2 Replies
Message 1 of 3

Assembly Events for deleting WorkPoint / WorkPlane

FINET_Laurent
Advisor
Advisor

Dear all, bonjour. 

Here bellow one code snippeds that will fire an event when deleting an occurrence inside an assembly (with several cuts for clarity) : 

 

        Private WithEvents asmEvents As Inventor.AssemblyEvents

        Public Sub Activate(ByVal addInSiteObject As Inventor.ApplicationAddInSite, ByVal firstTime As Boolean) Implements Inventor.ApplicationAddInServer.Activate
            g_inventorApplication = addInSiteObject.Application
            asmEvents = g_inventorApplication.AssemblyEvents

        End Sub

        Private Sub asmEvents_OnDelete(ByVal DocumentObject As AssemblyDocument, ByVal Occurrence As ComponentOccurrence, ByVal BeforeOrAfter As EventTimingEnum, ByVal Context As NameValueMap, ByRef HandlingCode As HandlingCodeEnum) Handles asmEvents.OnDelete
            MsgBox("Test")

        End Sub

 
It works fantastic, but that doesn't trigger when deleting work points or work planes, which seems normal to me. How could I achieve such behaviour, maybe using an other existing event that I'm not aware of ? 


Note that I would need to get the handles on that WorkPoint / WorkPlane that get deleted somehow.


Kind regards, 

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

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

FINET_Laurent
Advisor
Advisor
Accepted solution

Hellooooooo,

 

Got it thank you ❤️ 

        Private WithEvents _DocEvents As DocumentEvents

        Private Sub TestButton_OnExecute() Handles TestButton.OnExecute
            Dim doc As AssemblyDocument = g_inventorApplication.ActiveDocument
            _DocEvents = doc.DocumentEvents

        End Sub

        Private Sub test(ByVal Entity As Object, ByVal BeforeAfter As EventTimingEnum, ByVal Context As NameValueMap, ByRef HandlingCode As HandlingCodeEnum) Handles _DocEvents.OnDelete

            Dim WorkPoint As WorkPoint = Entity
            MsgBox(WorkPoint.Point.X)
        End Sub


Kind regards,

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

Message 3 of 3

mateusz_baczewski
Advocate
Advocate

Hi, I just have a quick question—does such an event handler need to be implemented as an Inventor add-in?

If you found it helpful, a "Like" would be much appreciated!
If this post solved your problem, please mark it as "Solution.".

0 Likes