def GetLvlDist(lvl_id):
    # print("------------")
    lvl_name = CnvrtToName(lvl_id)
    if ("OKRF" in lvl_name) and ("OKFF" in lvl_name):
        # print([0, lvl_name])
        lvl_name_new = re.sub("_.*", "_UKRD", lvl_name)
        # print(["new bottom level: ", lvl_name_new])
    elif "OKRF" in lvl_name:
        # print([1, lvl_name])
        lvl_name_new = lvl_name.replace("OKRF", "UKRD")
        # print(["new bottom level: ", lvl_name_new])
    elif "OKFF" in lvl_name:
        # print([2, lvl_name])
        lvl_okrf = GetLvlOKRF(lvl_name)
        lvl_id = lvl_okrf.id
        lvl_name_new = lvl_name.replace("OKFF", "UKRD")
        # print(["new bottom level: ", lvl_name_new])
    current_lvl = Document.GetElement(doc, lvl_id)
    # print(["new top level: ", current_lvl.Name])
    current_lvl_elev_double = current_lvl.get_Parameter(
        Bip.LEVEL_ELEV).AsDouble()
    current_lvl_elev = ToInt(current_lvl_elev_double)
    for level in level_info:
        if lvl_name_new == level.name:
            # print(current_lvl_elev)
            # print(level.elevation)
            dist = current_lvl_elev - level.elevation
    # print(dist)
    return dist
def process_storage_type(param_check):
    #determine parameter storage type
    try:
        if param_check.StorageType == DB.StorageType.Double:
            param = param_check.AsDouble()
        elif param_check.StorageType == DB.StorageType.Integer:
            param = param_check.AsInteger()
        elif param_check.StorageType == DB.StorageType.String:
            param = param_check.AsString()
        elif param_check.StorageType == DB.StorageType.ElementId:
            param_id = param_check.AsElementId()
            param_name = Document.GetElement(doc, param_id).Name
            level_loc = regex_lvl.findall(param_name)
            param = level_loc[0]
        else:
            print("Cannot read Parameter, sorry :(")
        return param
    except:
        pass
Example #3
0
def CnvrtToName(id):
    # Convert level ID to level Name
    lvl_name = Document.GetElement(doc, id).Name
    return lvl_name
Example #4
0
                try:
                    element_ids.append(id)
                    name = elem.Name
                    attached = 0
                    if elem.Category.Name == "Wände":
                        type_id = elem.WallType.Id
                        # print([1, type_id])
                        attached += elem.get_Parameter(
                            Bip.WALL_TOP_IS_ATTACHED).AsInteger()
                        attached += elem.get_Parameter(
                            Bip.WALL_BOTTOM_IS_ATTACHED).AsInteger()
                        # print(attached)
                    elif elem.Category.Name == "Geschossdecken":
                        type_id = elem.FloorType.Id
                        # print([2, type_id])
                    elem_type = Document.GetElement(doc, type_id)
                    # print(elem_type)
                    structure = elem_type.GetCompoundStructure(
                    ).StructuralMaterialIndex
                    # print(structure)
                    elem_info.append(
                        StructuralElement(id, structure, attached, name))
                except:
                    pass
        except:
            pass

# test columns and framing for structural property and append true elemets to list
for elem in struct_elems2:
    try:
        id = elem.Id
Example #5
0
            list_flatten(i)
        else:
            return i


# count all elements of certain BuiltInCategory -------------------------------
def Count_Bic(built_in_category):
    bic_name = str(built_in_category).replace("OST_", "")
    bic_elems = Fec(doc).OfCategory(
        built_in_category).WhereElementIsNotElementType().ToElements()
    return [len(bic_elems), bic_name]


# Warnings -------------------------------------------------------------------
# get all warnings
warning_elem = Document.GetWarnings(doc)

# elements with warnings
failing_elems_ids = []

for elem in warning_elem:
    failing_elem = elem.GetFailingElements()
    failing_elems_ids.append(failing_elem)

# fatten data structure and get ids of elements
warnings = []

for fail in failing_elems_ids:
    warnings.append(list_flatten(fail))

# all model elements ----------------------------------------------------------
Example #6
0
def jt_toInternalUnits(lengthValue):
    return UnitUtils.ConvertToInternalUnits(
        lengthValue,
        Document.GetUnits(doc).GetFormatOptions(
            UnitType.UT_Length).DisplayUnits)
def GetElemProps0(elem_lst):
    # this function takes all elements in the categories list and creates an object of the
    # StructuralElement class and appends it to the elem_info list.
    for elem in elem_lst:
        try:
            id = elem.Id
            name = elem.Name
            attached = 0
            if elem.Category.Name == "Geschossdecken":
                if elem.get_Parameter(
                        Bip.FLOOR_PARAM_IS_STRUCTURAL).AsInteger() == 1:
                    element_ids.append(id)
                    offset_raw = elem.get_Parameter(
                        Bip.FLOOR_HEIGHTABOVELEVEL_PARAM).AsDouble()
                    # print([1, offset_raw])
                    offset = ToInt(offset_raw)
                    if ui_select == 1:
                        lvl_bott_id = elem.get_Parameter(
                            Bip.LEVEL_PARAM).AsElementId()
                        thickness = ToInt(
                            elem.get_Parameter(
                                Bip.FLOOR_ATTR_THICKNESS_PARAM).AsDouble())
                        type_id = elem.FloorType.Id
                        # print([2, type_id])
                        elem_type = Document.GetElement(doc, type_id)
                        compound_struc = elem_type.GetCompoundStructure()
                        structure_idx = compound_struc.StructuralMaterialIndex
                        # print(structure_idx)
                        if structure_idx != -1:
                            structure_width_double = compound_struc.GetLayerWidth(
                                structure_idx)
                            structure_width = ToInt(structure_width_double)
                            lvl_dist = GetLvlDist(lvl_bott_id)
                            difference = lvl_dist - structure_width
                            # print(structure_width)
                            # print(difference)
                            # print(id)
                            if difference != 0:
                                offset = offset + difference
                                text_note = " Structural layer width differs from level distance."
                                elem_wrngs.append(
                                    WarningElement(id, name, text_note))
                            # print(offset, "----------------------------")
                    elem_info.append(StructuralElement(id, offset, attached))
            elif elem.Category.Name == "Skelettbau":
                element_ids.append(id)
                offset_raw = elem.get_Parameter(Bip.Z_OFFSET_VALUE).AsDouble()
                offset = ToInt(offset_raw)
                elev_0 = ToInt(
                    elem.get_Parameter(
                        Bip.STRUCTURAL_BEAM_END0_ELEVATION).AsDouble())
                elev_1 = ToInt(
                    elem.get_Parameter(
                        Bip.STRUCTURAL_BEAM_END1_ELEVATION).AsDouble())
                if ((elev_0 != 0) or (elev_1 != 0)):
                    attached = 1
                    text_note = " has Start- or Endebenenversatz." \
                    " Only allowed on slanted framing. Use z-Versatzwert."
                    elem_wrngs.append(WarningElement(id, name, text_note))
                elif ui_select == 1:
                    elev_top = ToInt(
                        elem.get_Parameter(
                            Bip.STRUCTURAL_ELEVATION_AT_TOP).AsDouble())
                    elev_bott = ToInt(
                        elem.get_Parameter(
                            Bip.STRUCTURAL_ELEVATION_AT_BOTTOM).AsDouble())
                    height = elev_top - elev_bott
                    offset = offset - height
                elem_info.append(StructuralElement(id, offset, attached))
            else:
                pass
        except:
            pass
Example #8
0
color_none = Autodesk.Revit.DB.Color(200, 200, 200)
color_none2 = Autodesk.Revit.DB.Color(123, 123, 123)

# create graphical overrides
ogs_true = OverrideGraphicSettings().SetProjectionFillColor(color_true)
ogs_true.SetProjectionFillPatternId(solid_fill)
ogs_true.SetSurfaceTransparency(0)
ogs_true.SetProjectionLineColor(color_true2)

ogs_none = OverrideGraphicSettings().SetProjectionFillColor(color_none)
ogs_none.SetProjectionFillPatternId(solid_fill)
ogs_none.SetSurfaceTransparency(40)
ogs_none.SetProjectionLineColor(color_none2)

# get all warnings
warnings = Document.GetWarnings(doc)


#  flatten list function
def list_flatten(elem_list):
    for i in elem_list:
        if type(i) == list:
            list_flatten(i)
        else:
            fail = i
    return fail


# elements with warnings
failing_elems_ids = []