Document.NewFootPrintRoof
Method
Description:
Creates a new FootPrintRoof element.
Creates a new FootPrintRoof element.
Remarks:
This method will regenerate the document even in manual regeneration mode.
This method will regenerate the document even in manual regeneration mode.
Syntax
public FootPrintRoof NewFootPrintRoof(
CurveArray footPrint,
Level level,
RoofType roofType,
out ModelCurveArray footPrintToModelCurvesMapping
)
Examples
// Before invoking this sample, select some walls to add a roof over.
// Make sure there is a level named "Roof" in the document.
// find the Roof level
FilteredElementCollector collector = new FilteredElementCollector(document);
collector.OfClass(typeof(Level));
var elements = from element in collector where element.Name == "Roof" select element;
Level level = elements.Cast<Level>().ElementAt<Level>(0);
collector = new FilteredElementCollector(document);
collector.OfClass(typeof(RoofType));
RoofType roofType = collector.FirstElement() as RoofType;
// Get the handle of the application
Autodesk.Revit.ApplicationServices.Application application = document.Application;
// Define the footprint for the roof based on user selection
CurveArray footprint = application.Create.NewCurveArray();
UIDocument uidoc = new UIDocument(document);
ICollection<ElementId> selectedIds = uidoc.Selection.GetElementIds();
if (selectedIds.Count != 0)
{
foreach (ElementId id in selectedIds)
{
Element element = document.GetElement(id);
Wall wall = element as Wall;
if (wall != null)
{
LocationCurve wallCurve = wall.Location as LocationCurve;
footprint.Append(wallCurve.Curve);
continue;
}
ModelCurve modelCurve = element as ModelCurve;
if (modelCurve != null)
{
footprint.Append(modelCurve.GeometryCurve);
}
}
}
else
{
throw new Exception("You should select a curve loop, or a wall loop, or loops combination \nof walls and curves to create a footprint roof.");
}
ModelCurveArray footPrintToModelCurveMapping = new ModelCurveArray();
FootPrintRoof footprintRoof = document.Create.NewFootPrintRoof(footprint, level, roofType, out footPrintToModelCurveMapping);
ModelCurveArrayIterator iterator = footPrintToModelCurveMapping.ForwardIterator();
iterator.Reset();
while (iterator.MoveNext())
{
ModelCurve modelCurve = iterator.Current as ModelCurve;
footprintRoof.set_DefinesSlope(modelCurve, true);
footprintRoof.set_SlopeAngle(modelCurve, 0.5);
}
Parameters
Parameter | Type | Description |
---|---|---|
footPrint | CurveArray | The footprint of the FootPrintRoof. |
level | Level | The level of the FootPrintRoof. |
roofType | RoofType | Type of the FootPrintRoof. |
footPrintToModelCurvesMapping | ModelCurveArray | An array of Model Curves corresponding to the set of Curves input in the footPrint. By knowing which Model Curve was created by each footPrint curve, you can set properties like SlopeAngle for each curve. |
Return Value
Exceptions
Exception | Condition |
---|---|
ArgumentException | Thrown if the level does not exist in the given document. |
ArgumentException | Thrown if the roof type does not exist in the given document. |