Cancel Command when switching documents

Cancel Command when switching documents

SRSDS
Advisor Advisor
713 Views
2 Replies
Message 1 of 3

Cancel Command when switching documents

SRSDS
Advisor
Advisor

If I have an active command that is in the midst of a transaction when switching documents (say inserting a block) how do I ensure that transaction is closed before the switch occurs? 

I have a counter that monitors opened and closed transactions and it triggers a warning when I do. 

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

FRFR1426
Collaborator
Collaborator
Accepted solution

The document switch can only occurs when you're using an interactive method like Editor.Getxxx(). In this case, the returned status will be PromptStatus.Cancel. You can then commit your transaction (if it is what you mean by "close the transaction").

 

PromptPointResult result = editor.GetPoint("\nInsertion point: ");
if (result.Status == PromptStatus.Cancel) 
{
  transaction.Commit();
  // Note: the transaction need to be disposed, you have to put it in an using.
  return;
}

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
Message 3 of 3

SRSDS
Advisor
Advisor

Thankyou. You're right, it does complete the code.

The DocumentToBeDeactivated handler executes then it reverts to finish. Which I didn't realise.

I need to adjust my transaction count error warnings for that. 

Thanks!

 

 

 

0 Likes