« Add-In Wizard for Revit 2013 | Main | Migrate Building Coder Samples to Revit 2013 »

April 18, 2012

Comments

Hi Jeremy,

Thanks for this. Should we also use Try...Catch blocks as well? Do we need to Rollback the exception or does the Using block take care of that?

Thanks again,
-Danny

using (Transaction trans = new Transaction(doc)) {
try {
trans.Start();
//code here
trans.Commit();
} catch (Exception ex) {
trans.Rollback();
//exception code here
}
}

Sorry, "do we need to Rollback the" *transaction*?

I'm with Danny here, prefer to gracefully fail so use this format:

TransactionGroup group;
try
{
using (group= new TransactionGroup(doc))
{
group.Start("Some group");
...
}
}
catch (Exception)
{
if (group.HasStarted() && !group.HasEnded()) group.RollBack();
}

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Your Information

(Name and email address are required. Email address will not be displayed with the comment.)

Jeremy Tammik

AboutTopicsIndexSource