public Result Execute(
ExternalCommandData revit,
ref string message,
ElementSet elements)
{
UIApplication uiapp = revit.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Document doc = uidoc.Document;
Selection sel = uidoc.Selection;
Reference ref1 = sel.PickObject(
ObjectType.Element, "Please pick a floor." );
Floor f = doc.GetElement( ref1 ) as Floor;
if( f == null )
return Result.Failed;
// Retrieve floor edge model line elements.
ICollection<ElementId> deleted_ids;
using( Transaction tx = new Transaction( doc ) )
{
tx.Start( "Temporarily Delete Floor" );
deleted_ids = doc.Delete( f.Id );
tx.RollBack();
}
// Grab the first floor edge model line.
ModelLine ml = null;
foreach( ElementId id in deleted_ids )
{
ml = doc.GetElement( id ) as ModelLine;
if( null != ml )
{
break;
}
}
if( null != ml )
{
using( Transaction tx = new Transaction( doc ) )
{
tx.Start( "Change Slope Angle" );
// This parameter is read only. Therefore,
// the change does not work and we cannot
// change the floor slope angle after the
// floor is created.
ml.get_Parameter(
BuiltInParameter.CURVE_IS_SLOPE_DEFINING )
.Set( 1 );
ml.get_Parameter(
BuiltInParameter.ROOF_SLOPE )
.Set( 1.2 );
tx.Commit();
}
}
return Result.Succeeded;
}