iLogic Undo Wrapper


@ClintBrown3D Autodesk Inventor 02

If you have created iLogic code that affects multiple properties or elements in Inventor, you may have noticed that although you run a single rule, you may have to click undo several times to get back to where you started. This is because each step is recorded in memory as a transaction.

The iLogic code below includes an “undo wrapper”, see Brian Ekins blog post here, explaining the concept of turning your code into a single transaction that can then be undone with a single undo.

Here is an excerpt from Brian’s blog post:

“You can combine multiple actions into a single undo using transactions.  A transaction is any action that can be undone.  Many, if not most, API calls are not transacted… To combine a set of actions into a single undo the API allows you to create your own transaction which wraps the other transactions.”

Here is the code that you can re-use.

'Original Code by @ClintBrown3D posted at
'Based on Brian Ekins Blog post: 
oDoc = ThisDoc.Document
Dim CADTIP As String = "@ClintBrown3D"
Dim UNDO As Transaction 
UNDO = ThisApplication.TransactionManager.StartTransaction(oDoc, oNamer)
'Your iLogic code goes in here: