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 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.
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();
}
}
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.