M

Document.NewFloor

Description:
Creates a floor within the project with the given horizontal profile and floor style on the specified level with the specified normal vector.
Remarks:
The curves of the profile must be contiguous and the Face formed by profile should be suitable to create floor.
Overloads (3):
NewFloor(CurveArray,FloorType,Level,Boolean,XYZ)
public Floor NewFloor(
	CurveArray profile,
	FloorType floorType,
	Level level,
	bool structural,
	XYZ normal
)
  • profile
    An array of planar lines and arcs that represent the horizontal profile of the floor.
  • floorType
    A floor type to be used by the new floor instead of the default type.
  • level
    The level on which the floor is to be placed.
  • Boolean
    structural
    If set, specifies that the floor is structural in nature.
  • normal
    A vector that must be perpendicular to the profile which dictates which side of the floor is considered to be upper and down.
Return Value nullNothingnullptr if successful, a new floor object within the project, otherwise null Nothing nullptr a null reference ( Nothing in Visual Basic) .
Floor CreateFloor(UIApplication application, Level level)
{
    // Get the Revit document
    Autodesk.Revit.DB.Document document = application.ActiveUIDocument.Document;

    // Get the application creation object
    Autodesk.Revit.Creation.Application appCreation = application.Application.Create;

    // Get a floor type for floor creation
    FilteredElementCollector collector = new FilteredElementCollector(document);
    collector.OfClass(typeof(FloorType));
    FloorType floorType = collector.FirstElement() as FloorType;

    // 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);
    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));

    // The normal vector (0,0,1) that must be perpendicular to the profile.
    XYZ normal = XYZ.BasisZ;

    return document.Create.NewFloor(profile, floorType, level, true, normal);
}