In default, if the option [Don’t run automatically] is not checked, the iLogic rule will execute automatically, updating with the newest parameters value when the parameters changed.
Or, you could specify which rule needs to execute by iLogic Trigger.
But, sometimes, you want only to execute the rule when the specific parameter(s) changed. The two ways above cannot help.
The ModelingEvents.OnParameterChange of Inventor API can know which parameter changed, but it means you would have more effort to work with Inventor events, which may be a challenge to some iLogic users.
Here is one workaround:
You could provide one global file (say "GlobalV.txt") to store the last values of parameters, e.g. assume we have two parameters: Width and Length. When parameter(s) changed, the rule runs. It will check the values in "GlobalV.txt" with current values of parameters. If only Width changed, run the corresponding workflow. If Length changed, run the other corresponding workflow. Finally update "GlobalV.txt" with the newest values for next use. Following is a code snippet:
'get project path
Dim oProjPath
oProjPath = ThisApplication.DesignProjectManager.ActiveDesignProject
'get full path of "GlobalV.txt"
Dim strGobalVFileName
strGobalVFileName = oProjPath.WorkspacePath & "GlobalV.txt"
If Not System.IO.File.Exists(strGobalVFileName) Then
' if "GlobalV.txt" does not exist
MsgBox ("GlobalV.txt does bnot exist in work path!")
Else
' read "GlobalV.txt"
Dim lines() As String
lines = System.IO.File.ReadAllLines(strGobalVFileName)
'assume the first line is for Width
globalV_Width = lines(0)
'assume the second line is for Length
globalV_Length = lines(1)
' if global width is different to current width
If Width <> globalV_Width Then
' do work for Width changing
End If
' if global length is different to current length
If Length <> globalV_Length Then
' do work for Length changing
End If
' now update "GlobalV.txt" with newest Width and Length for next use.
lines = System.IO.File.ReadAllLines(strGobalVFileName)
lines(0) = Width
lines(1) = Length
System.IO.File.WriteAllLines(strGobalVFileName, lines)
End If