Inventor Customization

Reply
Mentor
bsee1
Posts: 208
Registered: ‎11-14-2011
Message 1 of 5 (178 Views)
Accepted Solution

Transaction is forgotten

178 Views, 4 Replies
12-26-2012 01:24 PM

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
ADN Support Specialist
Posts: 467
Registered: ‎06-02-2009
Message 2 of 5 (156 Views)

Re: Transaction is forgotten

01-08-2013 12:41 AM 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

Mentor
bsee1
Posts: 208
Registered: ‎11-14-2011
Message 3 of 5 (146 Views)

Re: Transaction is forgotten

01-08-2013 05:59 AM 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
ADN Support Specialist
Posts: 467
Registered: ‎06-02-2009
Message 4 of 5 (142 Views)

Re: Transaction is forgotten

01-09-2013 06:06 AM 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

Mentor
bsee1
Posts: 208
Registered: ‎11-14-2011
Message 5 of 5 (131 Views)

Re: Transaction is forgotten

01-10-2013 05:35 AM 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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube