Using ProgressBar.OnCancel Event

Using ProgressBar.OnCancel Event

MechMachineMan
Advisor Advisor
3,186 Views
6 Replies
Message 1 of 7

Using ProgressBar.OnCancel Event

MechMachineMan
Advisor
Advisor
Application.CreateProgressBar( DisplayInStatusBar As Boolean, NumberOfSteps As Long, Title As String, [AllowCancel] As Boolean, [HWND] As Long ) As ProgressBar

 

Given the progress bar has the option to allow cancel, I was wondering how it is to be used within a Rule if it can even be used in that environment.

 

I have looked into the whole Handles and WithEvents thing, but have gotten lost. I don't have much background with programming aside from iLogic so I'm kind of stuck here.

 

ie; making the cancel button work for this snippet, directly in a rule:

 

Dim oProgressBar As Inventor.ProgressBar
oProgressBar = ThisApplication.CreateProgressBar(False, 10, "Test ProgressBar", True)

For j = 0 To 10
	oProgressBar.Message = ("Current Index: " & j & "/" & 10)
	Threading.Thread.Sleep(300)
	oProgressBar.UpdateProgress
Next

oProgressBar.Close

 

Any help would be appreciated.

 

Thanks! 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Accepted solutions (1)
3,187 Views
6 Replies
Replies (6)
Message 2 of 7

MechMachineMan
Advisor
Advisor
Any developments on this?

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 7

MechMachineMan
Advisor
Advisor

Hmmm....?


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 4 of 7

ekinsb
Alumni
Alumni
Accepted solution

I don't think iLogic is the best choice for something like this.  Writing code like this is quite painful just using the iLogic editor.  However, I was able to get it to work.  Here's the entire code of the rule.

 

Public Sub Main
    progBar = New TestProgressBar(ThisApplication)
    progBar.Start()
End Sub

Public Class TestProgressBar
    Private WithEvents progBar As Inventor.ProgressBar
    Private invApp As Inventor.Application

    Public Sub New(InventorApp As Inventor.Application)
        invApp = InventorApp
    End Sub

    Public Sub Start()
        progBar = invApp.CreateProgressBar(False, 10, "Test of Progress Bar", True)

        Dim j As Integer
        For j = 0 To 10
            progBar.Message = ("Current Index: " & j & "/" & 10)
            Threading.Thread.Sleep(1000)
            progBar.UpdateProgress()
        Next

        progBar.Close()
    End Sub

    Private Sub progBar_OnCancel() Handles progBar.OnCancel
        progBar.Close()
        MsgBox("Cancelled")
    End Sub
End Class

Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 5 of 7

MechMachineMan
Advisor
Advisor
Thank-you for your troubles! That should work for what I need it to!

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 6 of 7

Anonymous
Not applicable

 @MechMachineMan

Do you know how to get the progBar_OnCancel() sub to exit the rule after closing the progress bar?

0 Likes
Message 7 of 7

Maxim-CADman77
Advisor
Advisor

Judging by this cancelling iLogic rule is impossible.

Please vote for Inventor-Idea Text Search within Option Names

0 Likes