Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Transaction Limit?

J33C316
Advocate

Transaction Limit?

J33C316
Advocate
Advocate

I have an app that runs multiple transactions that vary in number. Some will not show up in Revit's undo list some of the time. The start and commit are getting hit every time in debug mode. Is there a transaction limit or some sort of undo limit in Revit? Thanks for your time.

0 Likes
Reply
705 Views
8 Replies
Replies (8)

jeremy_tammik
Autodesk
Autodesk

I am not aware of any such limit.

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes

J33C316
Advocate
Advocate

This is the part of the code that gets hit every time but doesn't always appear in Revit's undo. The app renumbers existing sheets and inserts a new sheet.

 

                            // changes sheet numbers of existing sheets
                            Transaction t = new Transaction(doc, "Renumbered Existing Sheet: " + exgSheetNumb + " to " + newSheetNumb);
                            FilteredElementCollector newsheets = new FilteredElementCollector(doc).OfClass(typeof(ViewSheet));
                            foreach (ViewSheet sht in newsheets)
                            {
                                if (sht.SheetNumber == exgSheetNumb)
                                {
                                    t.Start();
                                    sht.get_Parameter(BuiltInParameter.SHEET_NUMBER).Set(sht.SheetNumber.Replace(exgSheetNumb, newSheetNumb));
                                    t.Commit();
                                }
                            }

 

0 Likes

jeremy_tammik
Autodesk
Autodesk

Three separate suggestions; try one or the other or all three as you like:

 

  • Encapsulate your transaction in a `using` statement
  • Collect all your renumbering tasks first, and then execute them all in one single transaction
  • Encapsulate your multiple transactions into one single transaction group

  

Please also refer to the other discussions of handling transactions and transaction groups:

  

https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.53

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes

J33C316
Advocate
Advocate

Thanks Jeremy. I will try your suggestions. The strange thing is that it works the second time (and beyond) I run it but not the first time.

0 Likes

J33C316
Advocate
Advocate

Unfortunately I don't think there's an answer to my problem. This is really strange... If I save a new file based on a template to my hard drive it works every time. If I take that same file and put it on BIM 360 it no loner works. If I save it back down from BIM360 it still doesn't work. It's only broken on files that are on or have been on BIM 360. I can replicate this behavior over and over again and I get the same results.

0 Likes

jeremy_tammik
Autodesk
Autodesk

That sounds weird. Maybe the BIM360 folks have a helpful idea or related experience?

 

https://forums.autodesk.com/t5/bim-360/ct-p/2025

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes

J33C316
Advocate
Advocate

I let this sit on the shelf for a while but I just stumbled onto something that sheds some light on my problem. If I take ownership of of the views (sheet) before I run my code the program works perfectly and all transactions are available in the undo command. 

 

My code has a form and the user selects the sheets via a DataGridView. See attachment. The problem now is that I don't know how to take ownership "Editable" of the Views: Sheets using the API. I'll also need to release the ownership of the Views: Sheets before the program exits. I guess I could keep ownership until the user syncs but that is not very elegant. Any tips on how to programmatically take ownership via the API? Thanks!  

0 Likes

J33C316
Advocate
Advocate

I let this sit on the shelf for a while but I just stumbled onto something that sheds some light on my problem. If I take ownership of of the views (sheet) before I run my code the program works perfectly and all transactions are available in the undo command.

 

My code has a form and the user selects the sheets via a DataGridView. See attachment. The problem now is that I don't know how to take ownership "Editable" of the Views: Sheets using the API. I'll also need to release the ownership of the Views: Sheets before the program exits. I guess I could keep ownership until the user syncs but that is not very elegant. Any tips on how to programmatically take ownership via the API? Thanks!

 

Sorry I replied to the wrong message previously. Sorry for the duplication.

0 Likes