I can't make time to play, but
Have you seen Normans blog post
http://drive-cad-with-code.blogspot.com.au/2011/06/set-layout-in-order.html
I've seen that post. I wouldn't be averse to doing what it suggests if I could be assured it works as advertised. Right now, I am wanting to reorder a single tab up or down in the taborder.
I do have an idea that I will try and see of that resolves the issue.
Now that one of my old posts has been mentioned, let me chip in:
I think the reason of your code not working is because you simply try to change TabOrder of ONE layout, but did not try to change AFFECTED layout(s) (the ones before and/or after the one you change), which would result in duplicated TabOrder, thus exception when the Transaction is to commit. You see, there is always MODEL layout, which always has TabOrder=0. So, you cannot move layout with TabOrder=1 down. If the layout is has the max TabOrder, you cannot move it up. Therefore, when you say "re-order" layout tabs, it is actually SWAP TabOrder of 2 layouts: targeted one and the one before it (as long as it is not "MODEL"), or the one after it (as long as it is not the last one).
Once you understand this, things are really simple. Here is the code that works for me:
public static void SwapLayoutTabOrder(ObjectId lay1Id, ObjectId lay2Id)
{
using (var tran = lay1Id.Database.TransactionManager.StartTransaction())
{
var layout1 = (Layout)tran.GetObject(lay1Id, OpenMode.ForWrite);
var layout2 = (Layout)tran.GetObject(lay2Id, OpenMode.ForWrite);
var order1 = layout1.TabOrder;
var order2 = layout2.TabOrder;
layout1.TabOrder = order2;
layout2.TabOrder = order1;
tran.Commit();
}
}
The 2 arguments of the method are 2 layout's ObjectId, as long as none of them being "Model" layout.
I Just did a full demo-able project with UI to verify the code works as I expected. For the benefit of other possible readers to see the the code of entire project, I'll publish it in my blog later today, and post link here