Issue:
You have some iLogic code that prompts the user for a number of different inputs. But currently the features only update once the entire rule is run. You'd like for the features to update as the user steps through the input, so they have visual input as to what they've changed. And if each feature could be highlighted as it is selected by the iLogic code, so that the user knows which feature is being changed, that would be the cat's meow!
Solution:
To pull this off you need to use the following two lines after each input is gathered:
'If your rule has changed any parameter values, this will apply the new values to the Inventor model. If you don't use this, the values are not applied until the rule has finished running.
RuleParametersOutput()
'If this is included in a rule, iLogic will do an update for the document. This update is the same as the Update button in the user interface.
iLogicVb.UpdateWhenDone = True
To highlight the feature, simply change its color before the inputbox is issued, and then change it back immediately afterward. See the example code below.
Here is the example code:
'Start of iLogic Code--------------------------------------------------
'used to trigger rule for testing or running the rule
Trigger = iTrigger0
'ignores errors and continues on with the code
On Error Resume Next
'set the feature color to red and then prompts the user for input
'then pushes the parameter change to the part and updates before moving on
Feature.Color("Hole1") = "Red"
Dia1= InputBox("Enter Diameter of " & "Hole1", "iLogic Hole Diameter", Dia1)
Feature.Color("Hole1") = "As Part"
RuleParametersOutput()
iLogicVb.UpdateWhenDone = True
'set the feature color to red and then prompts the user for input
'then pushes the parameter change to the part and updates before moving on
Feature.Color("Hole2") = "Red"
Dia2= InputBox("Enter Diameter of " & "Hole2", "iLogic Hole Diameter", Dia2)
Feature.Color("Hole2") = "As Part"
RuleParametersOutput()
iLogicVb.UpdateWhenDone = True
'set the feature color to red and then prompts the user for input
'then pushes the parameter change to the part and updates before moving on
Feature.Color("Hole3") = "Red"
Dia3= InputBox("Enter Diameter of " & "Hole3", "iLogic Hole Diameter", Dia3)
Feature.Color("Hole3") = "As Part"
RuleParametersOutput()
iLogicVb.UpdateWhenDone = True
'set the feature color to red and then prompts the user for input
'then pushes the parameter change to the part and updates before moving on
Feature.Color("Hole4") = "Red"
Dia4= InputBox("Enter Diameter of " & "Hole4", "iLogic Hole Diameter", Dia4)
Feature.Color("Hole4") = "As Part"
RuleParametersOutput()
iLogicVb.UpdateWhenDone = True
'prompts the user for input
'then pushes the parameter change to the part and updates before moving on
Length= InputBox("Enter Length", "iLogic Length", Length)
RuleParametersOutput()
iLogicVb.UpdateWhenDone = True
'zoom all
ThisApplication.ActiveView.Fit
'End of iLogic Code--------------------------------------------------
Look for more iLogic examples on this blog or in the chapter dedicated to iLogic Basics in the next edition of Mastering Autodesk Inventor book (due out in June of 2011 if all goes well).
Look for more iLogic examples on this blog or in the chapter dedicated to iLogic Basics in the next edition of Mastering Autodesk Inventor book (due out in June of 2011 if all goes well).