Creates a floor within the project with the given horizontal profile and floor style on the specified level with the specified normal vector.
Namespace: Autodesk.Revit.Creation
Assembly: RevitAPI (in RevitAPI.dll) Version: 20.0.0.0 (20.1.1.1)
Syntax
Return Value
if successful, a new floor object within the project, otherwise
nullNothingnullptra null reference (Nothing in Visual Basic).
Remarks
Examples
CopyC#
Floor CreateFloor(UIApplication application, Level level)
{
Autodesk.Revit.DB.Document document = application.ActiveUIDocument.Document;
Autodesk.Revit.Creation.Application appCreation = application.Application.Create;
FilteredElementCollector collector = new FilteredElementCollector(document);
collector.OfClass(typeof(FloorType));
FloorType floorType = collector.FirstElement() as FloorType;
XYZ first = new XYZ(0, 0, 0);
XYZ second = new XYZ(20, 0, 0);
XYZ third = new XYZ(20, 15, 0);
XYZ fourth = new XYZ(0, 15, 0);
CurveArray profile = new CurveArray();
profile.Append(Line.CreateBound(first, second));
profile.Append(Line.CreateBound(second, third));
profile.Append(Line.CreateBound(third, fourth));
profile.Append(Line.CreateBound(fourth, first));
XYZ normal = XYZ.BasisZ;
return document.Create.NewFloor(profile, floorType, level, true, normal);
}
CopyVB.NET
Private Function CreateFloor(application As UIApplication, level As Level) As Floor
Dim document As Autodesk.Revit.DB.Document = application.ActiveUIDocument.Document
Dim appCreation As Autodesk.Revit.Creation.Application = application.Application.Create
Dim collector As New FilteredElementCollector(document)
collector.OfClass(GetType(FloorType))
Dim floorType As FloorType = TryCast(collector.FirstElement(), FloorType)
Dim first As New XYZ(0, 0, 0)
Dim second As New XYZ(20, 0, 0)
Dim third As New XYZ(20, 15, 0)
Dim fourth As New XYZ(0, 15, 0)
Dim profile As New CurveArray()
profile.Append(Line.CreateBound(first, second))
profile.Append(Line.CreateBound(second, third))
profile.Append(Line.CreateBound(third, fourth))
profile.Append(Line.CreateBound(fourth, first))
Dim normal As XYZ = XYZ.BasisZ
Return document.Create.NewFloor(profile, floorType, level, True, normal)
End Function
Exceptions
See Also