Create a floor, roof, ceiling, or lines from another #Revit element’s sketch

Simon posted in the forum looking for “the possibility to convert a floor to a ceiling by sketch or a roof by sketch and vice versa”. Yes, this can be done with the Revit API! You can find the source code here.

2 thoughts on “Create a floor, roof, ceiling, or lines from another #Revit element’s sketch

  1. i am trying to use same same fundamental for Area to Floor conversion .can you help me with this def area_to_floor(area, offset, level):
    new_floor = None

    try:
    # Make sure that Area is bounding.
    if not area.get_Parameter(BuiltInParameter.ROOM_AREA).AsDouble():
    return None

    # Check the shared parameter “Area Type” value
    area_type_param = area.LookupParameter(“Area Type”)

    if area_type_param:
    area_type_value = area_type_param.AsString()
    selected_floor_type = select_floor_type(area_type_value)

    # AREA BOUNDARIES
    #area_boundaries = area.GetBoundarySegments(SpatialElementBoundaryOptions())
    #sorted_curve_loops = sort_area_boundaries(area_boundaries)
    opt = DB.SpatialElementBoundaryOptions()
    print opt
    curve_loop = ExporterIFCUtils.GetRoomBoundaryAsCurveLoopArray(area, opt, True)
    print curve_loop

    with Transaction(doc, ‘Create Floor’) as t:
    t.Start()

    new_floor = Floor.Create(doc, curve_loop, selected_floor_type.Id, level.Id) #FIXME
    if new_floor:
    # SET OFFSET
    param = new_floor.get_Parameter(BuiltInParameter.FLOOR_HEIGHTABOVELEVEL_PARAM)
    param.Set(offset)

    failOpt = t.GetFailureHandlingOptions()
    failOpt.SetFailuresPreprocessor(FloorsCreationWarningSwallower())
    t.SetFailureHandlingOptions(failOpt)
    t.Commit()

    except:
    # print(traceback.format_exc())
    pass

    if new_floor:
    return new_floor

Leave a comment