[TransactionAttribute(TransactionMode.Manual)]
[RegenerationAttribute(RegenerationOption.Manual)]
class Class1 : IExternalCommand
{
public Result Execute(ExternalCommandData commandData,
ref string messege,
ElementSet elements)
{
Document doc = commandData.Application.ActiveUIDocument.Document;
const double mmToft = 0.00328084;
CurveArray profile = new CurveArray();
XYZ p1 = new XYZ(0, 0, 0);
XYZ p2 = new XYZ(4000 * mmToft, 0, 0);
XYZ p3 = new XYZ(4000 * mmToft, 4000 * mmToft, 0);
XYZ p4 = new XYZ(0, 4000 * mmToft, 0);
profile.Append(Line.CreateBound(p1, p2));
profile.Append(Line.CreateBound(p2, p3));
profile.Append(Line.CreateBound(p3, p4));
profile.Append(Line.CreateBound(p4, p1));
Level level = doc.ActiveView.GenLevel;
RoofType defaultType = doc.GetElement(doc.GetDefaultElementTypeId(ElementTypeGroup.RoofType)) as RoofType;
using (Transaction t = new Transaction(doc, "CreateRoof"))
{
t.Start();
ModelCurveArray footPrintToModelCurveMapping = new ModelCurveArray();
FootPrintRoof roof = doc.Create.NewFootPrintRoof(profile, level, defaultType, out footPrintToModelCurveMapping);
Parameter roomBoundaring = roof.get_Parameter(BuiltInParameter.WALL_ATTR_ROOM_BOUNDING);
roomBoundaring.Set(0);
t.Commit();
}
return Result.Succeeded;
}