Message 1 of 7
Ilogic Progress Bar

Not applicable
10-09-2018
08:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm wanting to put a progress bar in my rule below as on the larger assemblies it takes a couple of minutes to run.
I'm trying to count all the occurences in the assembly first to give the number of steps in my progress bar, and then everytime i go through to the next occurence move it on a step.
The one below only counts the top level occurences, and so if there is a large sub assembly, the progress bar stops for ages before it finishes the sub assembly, and moves onto the next occurence.
Is it possible to to count all occurences down all levels (and patterns) of the assembly and make the progress bar move a step when it goes through each one?
These recursive loops are hurting my brain!
SyntaxEditor Code Snippet
Sub Main() Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument Dim oCompDef As AssemblyComponentDefinition = oDoc.ComponentDefinition Dim oOcc_s As ComponentOccurrences = oCompDef.Occurrences Dim oUserParams As UserParameters = oCompDef.Parameters.UserParameters n=1 For Each oOcc As ComponentOccurrence In oOcc_s n=n+1 Next Dim iStepCount As Integer iStepCount = n Dim oDelay As Integer oDelay = 0 'set delay time Dim oProgressBar As Inventor.ProgressBar i=1 oMessage = "Updating... " oProgressBar = ThisApplication.CreateProgressBar(False, iStepCount, oMessage) oProgressBar.Message = ("Loading... " ) System.Threading.Thread.Sleep(oDelay) 'look at each occurrence in the assembly For Each oOcc As ComponentOccurrence In oOcc_s 'update params for each occurrence UpdateParam(oOcc,oUserParams) oProgressBar.Message = ("Updating Part " & i & " of " & iStepCount) oProgressBar.UpdateProgress System.Threading.Thread.Sleep(oDelay) i=i+1 Next oProgressBar.Close iLogicVb.UpdateWhenDone = True End Sub Sub UpdateParam(occ As ComponentOccurrence, params As Inventor.UserParameters) If Component.IsActive(occ.Name) = True Dim oParams As Parameters = occ.Definition.Parameters For Each param As UserParameter In params Try oParams(param.Name).Value = param.Value Catch End Try Next For Each subOcc As ComponentOccurrence In occ.SubOccurrences UpdateParam(subOcc, params) Next End If End Sub