Skip to content

Floor.Create(Document, IList.CurveLoop., ElementId, ElementId)

Public Class

Creates a new instance of architectural floor within the project.

Namespace: Autodesk.Revit.DB

Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)

Syntax

public static Floor Create(
Document document,
IList<CurveLoop> profile,
ElementId floorTypeId,
ElementId levelId
)

Parameters

document Document

The document in which the new floor is created.

profileIList. CurveLoop.

An array of planar curve loops that represent the profile of the floor.

floorTypeId ElementId

Id of the floor type to be used by the new Floor.

levelId ElementId

Id of the level on which the floor is to be placed.

Return Value

Floor
If successful a new floor object within the project.

Exceptions

Exception

Condition


ArgumentException

The ElementId levelId is not a Level. -or- The floorTypeId does not correspond to a FloorType. -or- The input curve loops cannot compose a valid boundary, that means: the “curveLoops” collection is empty; or some curve loops intersect with each other; or each curve loop is not closed individually; or each curve loop is not planar; or each curve loop is not in a plane parallel to the horizontal(XY) plane; or input curves contain at least one helical curve. -or- Input curves build invalid sketch. -or- Failed to create curve elements.


ArgumentNullException

A non-optional argument was null


InvalidOperationException

Cannot generate a sketch. -or- Failed to create new element.


ModificationForbiddenException

The document is in failure mode: an operation has failed, and Revit requires the user to either cancel the operation or fix the problem (usually by deleting certain elements). -or- The document is being loaded, or is in the midst of another sensitive process.


ModificationOutsideTransactionException

The document has no open transaction.


Remarks

To validate curve loop profile use BoundaryValidation. To get default floor type use

.

Example

/// The example below shows how to use Floor.Create method to create a new structural floor (slab) on one level
/// using a geometry profile and a floor type.
/// In this sample, the geometry profile is a CurveLoop of lines, you can also use arcs, ellipses and splines.
Floor CreateFloor(Document document, Level level)
{
// Get a floor type for floor creation
ElementId floorTypeId = Floor.GetDefaultFloorType(document, false);
// Build a floor profile for the floor creation
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);
CurveLoop profile = new CurveLoop();
profile.Append(Line.CreateBound(first, second));
profile.Append(Line.CreateBound(second, third));
profile.Append(Line.CreateBound(third, fourth));
profile.Append(Line.CreateBound(fourth, first));
return Floor.Create(document, new List<CurveLoop> { profile }, floorTypeId, level.Id);
}
/// The example below shows how to use Floor.Create method to create a new Floor with specified elevation, on one level
/// using a geometry profile and a floor type.
/// It shows how to adapt your code that used NewFloor and NewSlab methods, which are obsolete since 2022.
/// In this sample, the geometry profile is a CurveLoop of lines, you can also use arcs, ellipses and splines.
Floor CreateFloorAtElevation(Document document, double elevation)
{
// Get a floor type for floor creation
// You must provide a valid floor type (unlike in now obsolete NewFloor and NewSlab methods).
ElementId floorTypeId = Floor.GetDefaultFloorType(document, false);
// Get a level
// You must provide a valid level (unlike in now obsolete NewFloor and NewSlab methods).
double offset;
ElementId levelId = Level.GetNearestLevelId(document, elevation, out offset);
// Build a floor profile for the floor creation
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);
CurveLoop profile = new CurveLoop();
profile.Append(Line.CreateBound(first, second));
profile.Append(Line.CreateBound(second, third));
profile.Append(Line.CreateBound(third, fourth));
profile.Append(Line.CreateBound(fourth, first));
// The elevation of the curve loops is not taken into account (unlike in now obsolete NewFloor and NewSlab methods).
// If the default elevation is not what you want, you need to set it explicitly.
var floor = Floor.Create(document, new List<CurveLoop> { profile }, floorTypeId, levelId);
Parameter param = floor.get_Parameter(BuiltInParameter.FLOOR_HEIGHTABOVELEVEL_PARAM);
param.Set(offset);
return floor;
}