Example #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
Example #2
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
Example #3
0
        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,
                                     target_parameter_value, True)
    param_filter = DB.ElementParameterFilter(value_rule)
else:  #  value Strings
    """This param equality for this type is not available  in any language, so we go for for loop"""
    valuestring = True
    try:
        target_parameter_value = ele.Parameter[target_parameter].AsValueString(
        )  # As value strings got converted to strings
    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)

Example #4
0
            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)

# Create Filter strings
p_fil_a = DB.ElementParameterFilter(string_begins_with_12_Base)
p_fil_b = DB.ElementParameterFilter(string_begins_with_12_Tall)
p_fil_c = DB.ElementParameterFilter(string_begins_with_12_Case)