Are you using iLogic?
Several ways of getting code to run if a user parameter changes:
1) Set event trigger for Any Model Parameter Change, and reference the User parameter in a model parameter. This is a 'brute force' method and will obviously run every time any model param changes.
2) If the user parameter is explicitly referred to in the iLogic rule (and it therefore appears in blue text) then as long as the Options tab in the iLogic rule 'Don't run Automatically' is NOT ticked the rule will run whenever that specific parameter changes.
3) If you want a different method then you can create a 'memory' user parameter, e.g. Length_Memory and then use it as follows:
' Check if Length parameter has changed
If Not Length = Length_Memory Then
' Do Something
End If
' Set memory parameter again
Length_Memory = Length
Does this help?
Luke
Yes i work with iLogic.
The third part works fine.
' Check if Length parameter has changed
If Not Length = Length_Memory Then
' Do Something
End If
' Set memory parameter again
Length_Memory = Length
But i have 4 parameters to check and any of it start the same if-loop. Is there a way to do that without typing it 4 times?
Like:
If Not Length_* (* stands for any parameter with nearly the same name like Length_1, Length_2....)
'Do something
....
I used this:
If Not Length = LengthMemory OrElse Not Width = WidthMemory OrElse Not
Height = HeightMemory
Mode = 1
End If
Length = LengthMemory
Width = WidthMemory
Height = HeightMemory
But when i change one of the parameters nothing happens. Is there a mistake? I use this method because i want to keep it as simple as possible.
And i got an other problem. With:
Parameter.Quiet = True
Pos_1 = Parameter("Position_1")
If Not Pos_1 = Pos_Memory_1 Then
Mode = 1
End If
Pos_Memory_1 = Pos_1
I need the first two lines because the parameter is not existing all the time. But i need to check it for changes. Then the the parameter Mode =1 and an If Loop begins again! The If Loop updates the Model so you can see the position change!
MK92, you have got the statements at the end the wrong way round. It should read:
LengthMemory = Length
WidthMemory = Width
HeightMemory = Height
And for your second question - you should start a new post for this.