public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
UIApplication app = commandData.Application;
UIDocument uidoc = app.ActiveUIDocument;
Document doc = uidoc.Document;
Wall wall = Util.SelectSingleElementOfType(
uidoc, typeof( Wall ), "a wall", false )
as Wall;
if ( null == wall )
{
message
= "Please select a single wall element.";
return Result.Failed;
}
ICollection<ElementId> delIds = null;
using( Transaction t = new Transaction( doc ) )
{
try
{
t.Start( "Temporary Wall Deletion" );
delIds = doc.Delete( wall.Id );
t.RollBack();
}
catch ( Exception ex )
{
message = "Deletion failed: " + ex.Message;
t.RollBack();
}
}
WallFoundation footing = null;
foreach ( ElementId id in delIds )
{
footing = doc.GetElement( id ) as WallFoundation;
if( null != footing )
{
break;
}
}
string s = Util.ElementDescription( wall );
Util.InfoMsg( ( null == footing )
? string.Format( "No footing found for {0}.", s )
: string.Format( "{0} has {1}.", s,
Util.ElementDescription( footing ) ) );
return Result.Succeeded;
}