Beispiel #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
Beispiel #2
0
    def GetFirstTextNoteUsingType(doc, texttype):
        bip = DB.BuiltInParameter.ELEM_TYPE_PARAM
        provider = DB.ParameterValueProvider(ElementId(bip))
        evaluator = DB.FilterNumericEquals()
        rule = DB.FilterElementIdRule(provider, evaluator, texttype.Id)
        filter = DB.ElementParameterFilter(rule)

        fec = DB.FilteredElementCollector(doc, draftview.Id).OfClass(FilledRegion) \
              .WherePasses( filter ) \
              .FirstElement()
        return fec
Beispiel #3
0
def GetFirstWallUsingType(doc, walltype):
    bip = DB.BuiltInParameter.ELEM_TYPE_PARAM
    provider = DB.ParameterValueProvider(ElementId(bip))
    evaluator = DB.FilterNumericEquals()
    rule = DB.FilterElementIdRule(provider, evaluator, walltype.Id)
    filter = DB.ElementParameterFilter(rule)

    fec = DB.FilteredElementCollector(doc).OfClass(Wall) \
          .WherePasses( filter ) \
          .FirstElement()
    return fec
Beispiel #4
0
def GetFirstWallTypeNamed(doc, name):
    bip = DB.BuiltInParameter.SYMBOL_NAME_PARAM
    provider = DB.ParameterValueProvider(ElementId(bip))
    evaluator = DB.FilterStringEquals()
    rule = DB.FilterStringRule(provider, evaluator, name, False)
    filter = DB.ElementParameterFilter(rule)

    fec = FilteredElementCollector( doc).OfClass(DB.WallType) \
          .WherePasses(filter) \
          .FirstElement()
    return fec
def GetFirstDetailLineUsingType(doc, type, bip):
    bip = DB.BuiltInParameter.ELEM_TYPE_PARAM
    provider = DB.ParameterValueProvider(ElementId(bip))
    evaluator = DB.FilterNumericEquals()
    rule = DB.FilterElementIdRule(provider, evaluator, type.Id)
    filter = DB.ElementParameterFilter(rule)

    fec = DB.FilteredElementCollector(doc).OfCategory(DB.BuiltInCategory.OST_Lines) \
          .WherePasses( filter ) \
          .FirstElement()
    return fec
Beispiel #6
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
                target_parameter].AsValueString()
        except:
            forms.alert("Parameter {0} not found in {1}".format(
                selected_switch_parameter, category_name),
                        exitscript=True)
        decode_valuestring(target_parameter_value, target_category,
                           target_parameter)
    else:
        try:
            target_parameter_value = ele.Parameter[target_parameter].AsDouble()
        except:
            forms.alert("Parameter {0} not found in {1}".format(
                selected_switch_parameter, category_name),
                        exitscript=True)
        param_id = DB.ElementId(target_parameter)
        param_prov = DB.ParameterValueProvider(param_id)
        param_equality = DB.FilterNumericEquals()  # equality class for double
        value_rule = DB.FilterDoubleRule(param_prov, param_equality,
                                         target_parameter_value, 1e-3)
        param_filter = DB.ElementParameterFilter(value_rule)
elif selected_switch_parameter in ["Mark", "Comments"]:  # string values
    try:
        target_parameter_value = ele.Parameter[target_parameter].AsString()
    except:
        forms.alert("Parameter {0} not found in {1}".format(
            selected_switch_parameter, category_name),
                    exitscript=True)
    param_id = DB.ElementId(target_parameter)
    param_prov = DB.ParameterValueProvider(param_id)
    param_equality = DB.FilterStringEquals()  # equality class for string
    value_rule = DB.FilterStringRule(param_prov, param_equality,
Beispiel #8
0
# for timing -------------------------------------------------------------------
from pyrevit.coreutils import Timer
timer = Timer()
# ------------------------------------------------------------------------------


import Autodesk.Revit.DB as DB


doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument

height_param_id = DB.ElementId(DB.BuiltInParameter.WALL_USER_HEIGHT_PARAM)

height_param_prov = DB.ParameterValueProvider(height_param_id)

param_equality = DB.FilterNumericEquals()

heigh_value_rule = DB.FilterDoubleRule(height_param_prov,
                                       param_equality,
                                       10.0,
                                       1E-6)

param_filter = DB.ElementParameterFilter(heigh_value_rule)


walls = DB.FilteredElementCollector(doc) \
          .WherePasses(param_filter) \
          .ToElementIds()
Beispiel #9
0
    for p in pha:
        p_int = p.Id.IntegerValue
        if p_int == obj_phase:
            break
        else:
            count += 1
    return pha[count]


# Creating Collector instance and collecting all the casework from the model.

# Get Element Ids for all Families in project
family_name_id = DB.ElementId(DB.BuiltInParameter.ALL_MODEL_FAMILY_NAME)

# Get the Name of the Family
family_name_provider = DB.ParameterValueProvider(family_name_id)
# Create a Filter to look for specific text
filter_string_begin_with = DB.FilterStringBeginsWith()
# Filter for specific string
string_begins_with_12_Base = DB.FilterStringRule(family_name_provider,
                                                 filter_string_begin_with,
                                                 '12 BASE', 1)
#Filter for specific string
string_begins_with_12_Tall = DB.FilterStringRule(family_name_provider,
                                                 filter_string_begin_with,
                                                 '12 Tall', 1)
#Filter for specific string
string_begins_with_12_Case = DB.FilterStringRule(family_name_provider,
                                                 filter_string_begin_with,
                                                 '12  CASE - BASE', 1)