Joo Lee just submitted a comment pointing out an error or two in the flat migration of the CmdWallFooting command, which demonstrates an approach to retrieve the host reference using a wall footing:
Question: I tested your CmdWallFooting command in Revit Architecture 2011. But it does not work. The transaction is not started. How can I get the transaction to work?
Answer: Thank you very much for pointing this out!
This command was flat migrated from Revit 2010 and never tested. I tested it now as well and discovered two problems with it:
Fix 1: The read-only transaction mode causes the following error when trying to delete the wall: "Attempt to modify the model outside of transaction."
It can be fixed by specifying the transaction attribute like this:
[Transaction( TransactionMode.Automatic )]
Alterntively, you can specify manual transaction mode and start your own main transaction. That requires a little bit more coding and gives you full and explicit control in return.
Fix 2: The sub-transaction can be started by calling its Start method. Then the code to temporarily delete the wall looks like this:
SubTransaction t = new SubTransaction( doc ); ICollection<ElementId> delIds = null; try { t.Start(); delIds = doc.Delete( wall ); t.RollBack(); } catch ( Exception ex ) { message = "Deletion failed: " + ex.Message; t.RollBack(); return Result.Failed; }
Here is version 2011.0.74.3 of The Building Coder samples including the complete source code and Visual Studio solution with the updated command.
Thank you very much again, Joo Lee, for picking this up and pointing it out!