In my addin, I've wrapped a button click and everything the button does into a global transaction. If I only click the button once, the transaction can be undone with one undo. However, If I click my button twice, only the very latest transaction is undone properly. The previous transaction is no longer grouped.
Button click does these tasks:
The process: I click my button twice(giving enough time for it to finish each time), then click undo twice.
My expectation: Every action performed by both clicks of my button should be undone.
What is actually happening: The first undo click undoes every action performed by the very last button click. The next undo click undoes a single drawing of a sketched symbol. If I continue clicking undo, it will undo each of the sketched symbol drawings, one at a time. If I click it enough times, it will eventually undo drawing the table.
I thought transactions were supposed to "group" actions. Do I misunderstand how transactions work, or have I stumbled across a bug?
Code looks somethign like this:
Transaction transaction = default(Transaction); try { transaction = m_InventorApplication.TransactionManager.StartGlobalTransaction((_Document)aDoc, "readSymbols"); //read iProperties (calls a function from another class) //Draw table (calls function within this class) //Draw symbols (calls a function from another class) transaction.End(); } catch { transaction.End(); }
Solved! Go to Solution.
Solved by bsee1. Go to Solution.
Hi There,
It could be an issue, the way you describe it. Thing is the "StartGlobalTransaction" method is hidden/unsupported, which means you are using it at your own risk. Did you try the same scenario using "StartTransaction" instaed?
Another suggestion would be to wrap your command actions inside a ChangeProcessor, the topic is documented in the help files.
I hope it helps.
Regards,
Philippe.
The same problem happens with both transaction and global transaction.
I will get around to trying change processor, but for the time being, how should transactions work? I have a button click. When I define the transaction(not start it), should that go inside or outside of the button click? I've tried defining inside the button click, as well as defining it when the addin is initialized. Bother have the same effect. This is how I'm defining it.
Transaction transaction = default(Transaction);
I was under the impression global transactions were officially supported considering Brian Ekins mentioned them at AU2012 this year in the Inventor Odds and Ends presentation. This was one of his methods to speed processes up.
The way you declare the transaction should not matter in that case, as it is simply a reference to a Transaction object that only gets created by the TransactionManager when you call "StartTransaction" or "StartGlobalTransaction".
So far I was unable to reproduce the behavior you describe: I have an addin performing several sub operation inside a global transaction and I am able to undo each top level transaction as I'm pressing undo.
If you provide a minimal buildable sample project that allows us to easily reproduce the behavior, then we can take a closer look.
Concerning unsupported/hidden methods, an easy way to spot them is to check if they are mentionned in the Programming Help, or visible in the VBA object browser (this latter one also offers a "Show Hidden Members" option, that will display hidden objects and methods in lighter gray).
Regards,
Philippe.
The error was due to a coding error of mine. Transactions work as described in the documentation.
help us solve it, dont just stop there.
I have the same issue.
What did you do to solve this problem?