Ignore error on Transaction Abort

Ignore error on Transaction Abort

philip1009
Advisor Advisor
613 Views
2 Replies
Message 1 of 3

Ignore error on Transaction Abort

philip1009
Advisor
Advisor

I have a rule that's encompassed in a single transaction so if an error occurs it will abort and send the model back to it's previous state, but when it's aborted it still generates an error to click out of.  Here's the code sample below:

 

SyntaxEditor Code Snippet

oTxn=ThisApplication.TransactionManager.StartTransaction(ThisApplication.ActiveDocument,"Add Component")
On Error Goto Abort

'Bulk of Code

Goto EndRule

Abort:oTxn.Abort

EndRule:oTxn.End

Is there a way to evoke the oTxn.Abort line without generating an error pop-up?

 

Thanks in advance.

 

Philip Martick
Inventor 2018 Pro, AutoCAD 2018, Autodesk Vault Basic 2018
Windows 10 Pro
2X Intel Xeon E5-2630 v4 @ 2.20GHz
16.00 GB of RAM
NVIDIA Qudaro M2000 

0 Likes
Accepted solutions (1)
614 Views
2 Replies
Replies (2)
Message 2 of 3

MechMachineMan
Advisor
Advisor

It's not entirely clear what error you are having to click out of....

 

Sub Main()
oTxn=ThisApplication.TransactionManager.StartTransaction(ThisApplication.ActiveDocument,"Add Component") On Error Goto Abort 'Bulk of Code
Goto EndRule Abort:
oTxn.Abort Exit Sub EndRule:
oTxn.End

End Sub

--------------------------------------
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 3

philip1009
Advisor
Advisor
Accepted solution

I just figured out that you don't need to have a Transaction End after a Transaction Abort, I think trying to end a transaction after it's been aborted was generating the error.  The end of the rule just had to be rearranged like so:

 

SyntaxEditor Code Snippet

oTxn=ThisApplication.TransactionManager.StartTransaction(ThisApplication.ActiveDocument,"Add Component")
On Error Goto Abort

'Bulk of Code

oTxn.End
Goto EndRule
Abort:oTxn.Abort
EndRule:

On an error, the transaction is aborted and the rule ends, otherwise the code completed successfully and the transaction ends. 

0 Likes