The ProgressBar may not be a good fit for this situation, but I've attempted to create something you can try, if you want. I'm not sure if this will work for your situation or not, but I put some code together that will attempt to keep up with your rules running in the background. Keep in mind that some rules may finish running in just milliseconds, while other may take minutes, so it may not look that great, if it functions at all. When you use the UpdateProgress sub, it only increments the progress bar by one each time, but each time the loop code checks the value of the shared variable, there may have been several rules that have ran, so I'm not sure how it would handle that situation. I've set the initial value for the total number of steps the ProgressBar will take to 64. You can change this if you want, but you have to set this value when you create a progress bar. When it reaches that number it thinks it is done.
So, in order for this to have a chance of working, you would need to edit each rule that will be running, to add some code to them all. The added code will add one (1) to the SharedVariable named "RuleTally". This SharedVariable is a temporary variable that is stored in your session memory, so it is not saved in any document or to your hard drive. Keep in mind, if any rule has multiple possible results, this code may have to be in multiple locations within the rule, so that it gets ran no matter the result of the rule. The code for this would look something like this:
If SharedVariable.Exists("RuleTally") Then
SharedVariable("RuleTally") = SharedVariable("RuleTally") + 1
End If
Then here is the code for the rule that creates the ProgressBar:
Dim oRules As Integer = 64 'or your maximum # of rules
Dim oProgressBar As Inventor.ProgressBar = ThisApplication.CreateProgressBar(False, oRules, "RUNNING RULES", True)
oProgressBar.Message = "Processing Rules..."
'Create a local Integer type variable to hold the tally value and check against each time
Dim oRuleTally As Integer = 0
'Create the SharedVariable named "RuleTally" and set its value to the Integer variable's value
SharedVariable("RuleTally") = oRuleTally
For oRuleTally = SharedVariable("RuleTally") To oRules
If SharedVariable("RuleTally") > oRuleTally Then 'more rules have been processed
oRuleTally = SharedVariable("RuleTally")
oProgressBar.Message = "Processing Rule # " & oRuleTally & " Of " & oRules
oProgressBar.UpdateProgress
Else
'wait for the tally to increase, then loop again
System.Threading.Thread.Sleep(500) 'milliseconds (500 = half a second)
End If
Next
'only close the ProgressBar if it reaches the max number (oRules) or more
If oRuleTally >= oRules Then
oProgressBar.Message = "All Rules Have Been Processed."
oProgressBar.Close
End If
If the ProgressBar isn't going to work right for you, here's another similar idea you may be interested in. You could simply update the "StatusBarText" String value to show the progress textually, without the ProgressBar. You would still need to add the code to all the rules, but this may run smoother. The code is similar:
Dim oRules As Integer = 64 'or your maximum # of rules
ThisApplication.StatusBarText = "Please Wait...Processing Rules..."
'Create a local Integer type variable to hold the tally value and check agains each time
Dim oRuleTally As Integer = 0
'Create the SharedVariable named "RuleTally" and set its value to the Integer variable's value
SharedVariable("RuleTally") = oRuleTally
For oRuleTally = SharedVariable("RuleTally") To oRules
If SharedVariable("RuleTally") > oRuleTally Then 'more rules have been processed
oRuleTally = SharedVariable("RuleTally")
ThisApplication.StatusBarText = "Please Wait...Running Rule # " & oRuleTally & " Of " & oRules
Else
'wait for the tally to increase, then loop again
System.Threading.Thread.Sleep(500) 'milliseconds (500 = half a second)
End If
Next
If oRuleTally >= oRules Then
ThisApplication.StatusBarText = "All Rules Have Been Processed."
End If
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.
Wesley Crihfield

(Not an Autodesk Employee)