public Result Execute(
ExternalCommandData revit,
ref string message,
ElementSet elements)
{
UIApplication uiapp = revit.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Document doc = uidoc.Document;
using( Transaction tx = new Transaction( doc ) )
{
tx.Start( "Create Sloped Slab" );
double width = 19.685039400;
double length = 59.055118200;
double height = 9.84251968503937;
XYZ[] pts = new XYZ[] {
new XYZ( 0.0, 0.0, height ),
new XYZ( width, 0.0, height ),
new XYZ( width, length, height ),
new XYZ( 0, length, height )
};
CurveArray profile
= uiapp.Application.Create.NewCurveArray();
Line line = null;
int n = pts.GetLength( 0 );
XYZ q = pts[n - 1];
foreach( XYZ p in pts )
{
line = Line.CreateBound( q, p );
profile.Append( line );
q = p;
}
Level level
= new FilteredElementCollector( doc )
.OfClass( typeof( Level ) )
.Where<Element>(
e => e.Name.Equals( "CreateSlopedSlab" ) )
.FirstOrDefault<Element>() as Level;
if( null == level )
{
//level = doc.Create.NewLevel( height ); // 2015
level = Level.Create( doc, height ); // 2016
level.Name = "Sloped Slab";
}
Floor floor = doc.Create.NewSlab(
profile, level, line, 0.5, true );
tx.Commit();
}
return Result.Succeeded;
}