- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Do Loop to check multiple values and return a single result...maybe
Through a series of rules, I am creating iProperties to show whether a certain condition exists or not. Each of these properties will either end with a value of "Yes" or "No".
iProperties.Value("Custom", "Width Configured?")
iProperties.Value("Custom", "Honeycomb Configured?")
iProperties.Value("Custom", "Inner Rail 1 Configured?")
iProperties.Value("Custom", "Inner Rail 2 Configured?")I would like to create a rule to check the values of these 4 properties and perform one of two operations given the values of those properties.
If any one of the 4 iproperties = "No" Then
iLogicVb.RunRule("Width Check")
iLogicVb.RunRule("Panel Length - No Rails")
ElseIf ALL 4 properites = "Yes" Then
'MessageBox.Show("Part is properly configured. No changes needed.", "Limit Check")
End IfI assume I need to run a Do Loop to check the values of the properties and return one of the two outcomes I have shown above. If so, I don't know how to write the code. If there is another way, which way is it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @jfenter
This would be a very simple solution for your problem ![]()
Dim oCount As Integer = 0 If iProperties.Value("Custom", "Width Configured?") Then oCount += 1 If iProperties.Value("Custom", "Honeycomb Configured?") Then oCount += 1 If iProperties.Value("Custom", "Inner Rail 1 Configured?") Then oCount += 1 If iProperties.Value("Custom", "Inner Rail 2 Configured?") Then oCount +=1 If oCount < 4 iLogicVb.RunRule("Width Check") iLogicVb.RunRule("Panel Length - No Rails") Else MessageBox.Show("Part is properly configured. No changes needed.", "Limit Check") End If
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I don't think that will work, because the values of the iProperties will be Strings, and iLogic doesn't implicitly convert strings to boolean. You could change the other rules to make the values of your iProperties either "True" or "False", or you could use the below code to evaluate the current values:
If LCase(iProperties.Value("Custom", "Width Configured?")) = "no" Or _
LCase(iProperties.Value("Custom", "Honeycomb Configured?")) = "no" Or _
LCase(iProperties.Value("Custom", "Inner Rail 1 Configured?")) = "no" Or _
LCase(iProperties.Value("Custom", "Inner Rail 2 Configured?")) = "no" Then
iLogicVb.RunRule("Width Check")
iLogicVb.RunRule("Panel Length - No Rails")
Else
MessageBox.Show("Part is properly configured. No changes needed.", "Limit Check")
End If
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I dont see any reason not to use Yes/No-properties for this purpose.
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
My initial test of the suggested solution seems to be working, but I found an error in the rules that set the iProperties that is causing a "no" result when it should be a "yes". Unfortunately I've been forced into temporarily changing projects so I have to sit on this until I can continue debugging the rules.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This is another way to do it:
Sub Main
Dim StringList As String() ={"Width Configured?", "Honeycomb Configured?", "Inner Rail 1 Configured?", "Inner Rail 2 Configured?"} '{"Test", "This"}
If CheckThese(StringList) = False
MessageBox.Show("Part is not properly configured. Running rules now.", "Failed Limit Check")
' iLogicVb.RunRule("Width Check")
' iLogicVb.RunRule("Panel Length - No Rails")
Else
MessageBox.Show("Part is properly configured. No changes needed.", "Passed Limit Check")
End If
End Sub
Private Function CheckThese(oStrings As String()) As Boolean
Dim i As Integer = 0
While i < oStrings.Count
Result = False
Try
prop = iProperties.Value("Custom", oStrings(i))
Catch
MessageBox.Show("The iProperty: [ " & oStrings(i) & " ] is missing from this part!", "Missing iProperty")
Result = False
Exit While
End Try
If iProperties.Value("Custom", oStrings(i)) = True Then Result = True Else Exit While
i=i+1
End While
Return Result
End FunctionIt does the checking in a Private function, that returns to your main rule As a Boolean response. It is set up so you can check any number of Yes/No iProperties, and returns a False Boolean at the first False value found. It also handles missing iProperties by prompting the missing property name before returning a False Boolean.