Hi,
I was wondering if there was any way to get information about the event from within the handler assigned to it.
I have the same handler running on different triggers, each requiring a slightly different execution depending on the event type.
I know I can wrap this in a dedicated handler and parameterize a call to the rule from within this, but is there otherwise no way to get information about the event itself?
Thanks
Solved! Go to Solution.
Hi,
I was wondering if there was any way to get information about the event from within the handler assigned to it.
I have the same handler running on different triggers, each requiring a slightly different execution depending on the event type.
I know I can wrap this in a dedicated handler and parameterize a call to the rule from within this, but is there otherwise no way to get information about the event itself?
Thanks
Solved! Go to Solution.
Solved by Michael.Navara. Go to Solution.
I strongly recommend you to use separate rule for each event handler. In the background you can call one external rule with specific arguments.
But to your question. It is possible but it can be little bit obscure and behavior can change in future without any information because it is not part of public iLogic API.
This code snippet show how to access underlying .NET call stack and print the called methods to the iLogic log. You need to analyze this callstack and determine which event runs this rule
Imports System.Diagnostics
'Get Call stack
Dim stackTrace As New StackTrace()
' Get method calls (frames)
Dim stackFrames As StackFrame() = stackTrace.GetFrames()
For Each stackFrame As StackFrame In stackFrames
'Write method name
Logger.Debug(StackFrame.GetMethod().Name)
Next
My results for
Part Geometry Changed event | Before Save Document event |
INFO| 19: >>--------------------------- DEBUG|Main DEBUG|ExecRuleInAssembly DEBUG|ExecRuleEval DEBUG|EvalRule DEBUG|EvalRule DEBUG|RuleRun DEBUG|VisitRule DEBUG|RunListOfRules DEBUG|RunInternalRules DEBUG|OnSurfaceBodyChanged DEBUG|InvokeMethod DEBUG|UnsafeInvokeInternal DEBUG|Invoke | INFO| 20: >>--------------------------- DEBUG|Main DEBUG|ExecRuleInAssembly DEBUG|ExecRuleEval DEBUG|EvalRule DEBUG|EvalRule DEBUG|RuleRun DEBUG|VisitRule DEBUG|RunListOfRules DEBUG|RunInternalRules DEBUG|mobjApplicationEvents_OnSaveDocument DEBUG|InvokeMethod DEBUG|UnsafeInvokeInternal DEBUG|Invoke |
I strongly recommend you to use separate rule for each event handler. In the background you can call one external rule with specific arguments.
But to your question. It is possible but it can be little bit obscure and behavior can change in future without any information because it is not part of public iLogic API.
This code snippet show how to access underlying .NET call stack and print the called methods to the iLogic log. You need to analyze this callstack and determine which event runs this rule
Imports System.Diagnostics
'Get Call stack
Dim stackTrace As New StackTrace()
' Get method calls (frames)
Dim stackFrames As StackFrame() = stackTrace.GetFrames()
For Each stackFrame As StackFrame In stackFrames
'Write method name
Logger.Debug(StackFrame.GetMethod().Name)
Next
My results for
Part Geometry Changed event | Before Save Document event |
INFO| 19: >>--------------------------- DEBUG|Main DEBUG|ExecRuleInAssembly DEBUG|ExecRuleEval DEBUG|EvalRule DEBUG|EvalRule DEBUG|RuleRun DEBUG|VisitRule DEBUG|RunListOfRules DEBUG|RunInternalRules DEBUG|OnSurfaceBodyChanged DEBUG|InvokeMethod DEBUG|UnsafeInvokeInternal DEBUG|Invoke | INFO| 20: >>--------------------------- DEBUG|Main DEBUG|ExecRuleInAssembly DEBUG|ExecRuleEval DEBUG|EvalRule DEBUG|EvalRule DEBUG|RuleRun DEBUG|VisitRule DEBUG|RunListOfRules DEBUG|RunInternalRules DEBUG|mobjApplicationEvents_OnSaveDocument DEBUG|InvokeMethod DEBUG|UnsafeInvokeInternal DEBUG|Invoke |
But the problem is, if I try to programmatically remove a rule, I have to remove either the generic handler or create unique handlers to remove, for each rule in which I need to know the event type.
But the problem is, if I try to programmatically remove a rule, I have to remove either the generic handler or create unique handlers to remove, for each rule in which I need to know the event type.
Can't find what you're looking for? Ask the community or share your knowledge.