Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Transaction is forgotten

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
bsee1
436 Views, 4 Replies

Transaction is forgotten

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:

  • Read iProperties
  • Generate Table
  • Draw a bunch of sketched symbols

 

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();
}

 

 

*****************************
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000

Inventor 2013
ETO 6.1
4 REPLIES 4
Message 2 of 5
philippe.leefsma
in reply to: bsee1

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.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 5
bsee1
in reply to: philippe.leefsma

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.

*****************************
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000

Inventor 2013
ETO 6.1
Message 4 of 5
philippe.leefsma
in reply to: bsee1

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.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 5 of 5
bsee1
in reply to: bsee1

The error was due to a coding error of mine.  Transactions work as described in the documentation.

*****************************
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000

Inventor 2013
ETO 6.1

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report