DocumentNewFootPrintRoof Method |
Creates a new FootPrintRoof element.
Namespace: Autodesk.Revit.CreationAssembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntaxpublic FootPrintRoof NewFootPrintRoof(
CurveArray footPrint,
Level level,
RoofType roofType,
out ModelCurveArray footPrintToModelCurvesMapping
)
Public Function NewFootPrintRoof (
footPrint As CurveArray,
level As Level,
roofType As RoofType,
<OutAttribute> ByRef footPrintToModelCurvesMapping As ModelCurveArray
) As FootPrintRoof
public:
FootPrintRoof^ NewFootPrintRoof(
CurveArray^ footPrint,
Level^ level,
RoofType^ roofType,
[OutAttribute] ModelCurveArray^% footPrintToModelCurvesMapping
)
member NewFootPrintRoof :
footPrint : CurveArray *
level : Level *
roofType : RoofType *
footPrintToModelCurvesMapping : ModelCurveArray byref -> FootPrintRoof
Parameters
- 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
FootPrintRoof
ExceptionsException | 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. |
Remarks This method will regenerate the document even in manual regeneration mode.
Example
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;
Autodesk.Revit.ApplicationServices.Application application = document.Application;
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);
}
Dim collector As New FilteredElementCollector(document)
collector.OfClass(GetType(Level))
: Dim elements As System.Collections.Generic.IEnumerable(Of Autodesk.Revit.DB.Element)
elements = From element In collector _
Where element.Name = "Roof" _
Select element
Dim level As Level = elements.Cast(Of Level)().ElementAt(0)
collector = New FilteredElementCollector(document)
collector.OfClass(GetType(RoofType))
Dim roofType As RoofType = TryCast(collector.FirstElement(), RoofType)
Dim application As Autodesk.Revit.ApplicationServices.Application = document.Application
Dim footprint As CurveArray = application.Create.NewCurveArray()
Dim uidoc As New UIDocument(document)
Dim selectedIds As ICollection(Of ElementId) = uidoc.Selection.GetElementIds()
If selectedIds.Count <> 0 Then
For Each id As ElementId In selectedIds
Dim element As Element = document.GetElement(id)
Dim wall As Wall = TryCast(element, Wall)
If wall IsNot Nothing Then
Dim wallCurve As LocationCurve = TryCast(wall.Location, LocationCurve)
footprint.Append(wallCurve.Curve)
Continue For
End If
Dim modelCurve As ModelCurve = TryCast(element, ModelCurve)
If modelCurve IsNot Nothing Then
footprint.Append(modelCurve.GeometryCurve)
End If
Next
Else
Throw New Exception("You should select a curve loop, or a wall loop, or loops combination " & vbLf & "of walls and curves to create a footprint roof.")
End If
Dim footPrintToModelCurveMapping As New ModelCurveArray()
Dim footprintRoof As FootPrintRoof = document.Create.NewFootPrintRoof(footprint, level, roofType, footPrintToModelCurveMapping)
Dim iterator As ModelCurveArrayIterator = footPrintToModelCurveMapping.ForwardIterator()
iterator.Reset()
While iterator.MoveNext()
Dim modelCurve As ModelCurve = TryCast(iterator.Current, ModelCurve)
footprintRoof.DefinesSlope(modelCurve) = True
footprintRoof.SlopeAngle(modelCurve) = 0.5
End While
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
See Also