I am looking to create a trigger in my iLogic to code for when parameters are changed, so that based on the parameter changed specific code/subs are run. I found this topic and tried it in my code, but I get the following errors:
What am I doing wrong here? Is it possible to have a trigger event in an iLogic rule?
Sub Main()
Dim invApp As Inventor.Application
Dim modelingEvents As modelingEvents
invApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")
modelingEvents = invApp.ModelingEvents
AddHander modelingEvents.OnParameterChange, AddressOf modelingEvents_ParameterChange
End Sub
Sub modelingEvents_ParameterChange(documentObject As _Document, parameter As Parameter, beforeOrAfter As EventTimingEnum, context As NameValueMap, ByRef handlingCode As HandlingCodeEnum)
If beforeOrAfter = kBefore Then
'actions to do before the parameter changes (so with the 'old' value)
MessageBox.Show("kBefore trigger.")
ElseIf beforeOrAfter = kAfter Then
'actions to do after the parameter changes (so with the 'new' value)
MessageBox.Show("kAfter trigger.")
End If
End Sub
Solved! Go to Solution.
I am looking to create a trigger in my iLogic to code for when parameters are changed, so that based on the parameter changed specific code/subs are run. I found this topic and tried it in my code, but I get the following errors:
What am I doing wrong here? Is it possible to have a trigger event in an iLogic rule?
Sub Main()
Dim invApp As Inventor.Application
Dim modelingEvents As modelingEvents
invApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")
modelingEvents = invApp.ModelingEvents
AddHander modelingEvents.OnParameterChange, AddressOf modelingEvents_ParameterChange
End Sub
Sub modelingEvents_ParameterChange(documentObject As _Document, parameter As Parameter, beforeOrAfter As EventTimingEnum, context As NameValueMap, ByRef handlingCode As HandlingCodeEnum)
If beforeOrAfter = kBefore Then
'actions to do before the parameter changes (so with the 'old' value)
MessageBox.Show("kBefore trigger.")
ElseIf beforeOrAfter = kAfter Then
'actions to do after the parameter changes (so with the 'new' value)
MessageBox.Show("kAfter trigger.")
End If
End Sub
Solved! Go to Solution.
Solved by gert-leonvanlier. Go to Solution.
Ok, very stupid of me, I made a typo 😶. Now AddHandler is working and so are the triggers.
Ok, very stupid of me, I made a typo 😶. Now AddHandler is working and so are the triggers.
Can't find what you're looking for? Ask the community or share your knowledge.