Exemple #1
0
def get_piping_system_type(param_name):
    # Accesses the ID associated with the built-in paramater "System Classification"
    # See RevitApiDocs: BuiltInParameter Enumeration
    param_id = DB.ElementId(DB.BuiltInParameter.RBS_PIPING_SYSTEM_TYPE_PARAM)
    # The filter needs the ID of the parameter we are searching for:
    # See RevitApiDocs: FilterableValueProvider Class
    param_prov = DB.ParameterValueProvider(param_id)
    # The filter also takes a rule evaluation
    # See RevitApiDocs: FilterStringRuleEvaluator Look at the inheritance Heirarchy
    # to get an idea of what options this has.
    filter_rule = DB.FilterStringContains()
    # This line directly translates from the C# example provided in the documentation
    # to the python equivalent. See RevitApiDocs: ElementParameterFilter Class
    case_sensitive = False
    param_filter = DB.FilterStringRule(param_prov, \
                                            filter_rule, \
                                            param_name, \
                                            case_sensitive)
    # Assigns our filter to the element parameter filter so it fits into the
    # 'WherePasses' method
    element_filter = DB.ElementParameterFilter(param_filter)
    # Collect a list of items eligible to get picked by the filter.
    # I found OST_PipeCurves from a combination of looking over the built in categories and
    collected_elements = DB.FilteredElementCollector(doc) \
            .OfCategory(DB.BuiltInCategory.OST_PipeCurves) \
            .WherePasses(element_filter) \
            .ToElements()

    return collected_elements
Exemple #2
0
def get_railing_system():
    # Accesses the ID associated with the built-in paramater "System Classification"
    # See RevitApiDocs: BuiltInParameter Enumeration
    param_id = DB.ElementId(
        DB.BuiltInParameter.RAILING_SYSTEM_HANDRAILS_TYPES_PARAM)
    # The filter needs the ID of the parameter we are searching for:
    # See RevitApiDocs: FilterableValueProvider Class
    param_prov = DB.ParameterValueProvider(param_id)
    # The filter also takes a rule evaluation
    # See RevitApiDocs: FilterStringRuleEvaluator Look at the inheritance Heirarchy
    # to get an idea of what options this has.
    filter_rule = DB.FilterStringContains()
    # This line directly translates from the C# example provided in the documentation
    # to the python equivalent. See RevitApiDocs: ElementParameterFilter Class
    case_sensitive = False
    '''
    param_filter = DB.FilterStringRule(param_prov, \
                                            filter_rule, \
                                            param_name, \
                                            case_sensitive)
    '''
    # Assigns our filter to the element parameter filter so it fits into the
    # '.WherePasses(element_filter)' method
    '''
    element_filter = DB.ElementParameterFilter(param_filter)

    '''
    # Collect a list of items eligible to get picked by the filter.
    # I found OST_PipeCurves from a combination of looking over the built in categories and
    '''
    options for the collected elements
                .WhereElementIsNotElementType().
                .OfClass(typeof(FamilyInstance))
    '''
    collected_elements = []
    proj_stairs_railings = []
    proj_hand_railings = []
    proj_top_railings = []
    # print("\n" + "-" * 25 + "Stairs Railings: " + "-" * 25)
    stairs_railings = DB.FilteredElementCollector(doc) \
            .OfCategory(DB.BuiltInCategory.OST_StairsRailing) \
            .WhereElementIsNotElementType() \
            .ToElements()
    for rail in stairs_railings:
        collected_elements.append(rail)
        proj_stairs_railings.append(rail)
        # print(rail.Id)

    # print("\n" + "-" * 25 + "Hand Railings: " + "-" * 25)
    hand_railings = DB.FilteredElementCollector(doc) \
            .OfCategory(DB.BuiltInCategory.OST_RailingHandRail) \
            .WhereElementIsNotElementType() \
            .ToElements()
    for rail in hand_railings:
        collected_elements.append(rail)
        proj_hand_railings.append(rail)

        # print(rail.Id)

    # print("\n" + "-" * 25 + "Top Railings: " + "-" * 25)
    top_railings = DB.FilteredElementCollector(doc) \
            .OfCategory(DB.BuiltInCategory.OST_RailingTopRail) \
            .WhereElementIsNotElementType() \
            .ToElements()
    for rail in top_railings:
        collected_elements.append(rail)
        proj_top_railings.append(rail)
        # print(rail.Id)

    # for element in collected_elements:
    #     print(str(element))
    return collected_elements, proj_stairs_railings, proj_hand_railings, proj_top_railings