Ejemplo n.º 1
0
def get_viewport_types(doc=revit.doc):
    # get viewport types using a parameter filter
    bip_id = DB.ElementId(DB.BuiltInParameter.VIEWPORT_ATTR_SHOW_LABEL)
    bip_provider = DB.ParameterValueProvider(bip_id)
    rule = DB.FilterIntegerRule(bip_provider, DB.FilterNumericGreaterOrEqual(), 0)
    param_filter = DB.ElementParameterFilter(rule)

    collector = DB.FilteredElementCollector(doc) \
        .WherePasses(param_filter) \
        .WhereElementIsElementType()\
        .ToElements()

    return collector
Ejemplo n.º 2
0
def get_vp_by_name(name, doc=revit.doc):
    #
    bip_id = DB.ElementId(DB.BuiltInParameter.VIEWPORT_ATTR_SHOW_LABEL)
    bip_provider = DB.ParameterValueProvider(bip_id)
    rule = DB.FilterIntegerRule(bip_provider, DB.FilterNumericGreaterOrEqual(), 0)
    param_filter = DB.ElementParameterFilter(rule)

    type_bip_id = DB.ElementId(DB.BuiltInParameter.ALL_MODEL_TYPE_NAME)
    type_bip_provider = DB.ParameterValueProvider(type_bip_id)
    type_filter_rule = DB.FilterStringRule(type_bip_provider, DB.FilterStringEquals(), name, True)
    type_filter = DB.ElementParameterFilter(type_filter_rule)

    and_filter = DB.LogicalAndFilter(param_filter, type_filter)



    collector = DB.FilteredElementCollector(doc) \
        .WherePasses(and_filter) \
        .WhereElementIsElementType()\
        .FirstElement()

    return collector
Ejemplo n.º 3
0
# __context__ = 'Selection'

doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument
curview = doc.ActiveView  # gets current view

if isinstance(curview, DB.ViewSheet):
    forms.alert("You're on a Sheet. Activate a model view please.",
                exitscript=True)

length_feet = float(forms.ask_for_string(
    "Enter length in meters")) / 0.3048  # sometimes revit interprets 1 > 1.0
target_parameter = DB.BuiltInParameter.CURVE_ELEM_LENGTH  # FAMILY_TOP_LEVEL_PARAM, FAMILY_BASE_LEVEL_PARAM
param_id = DB.ElementId(target_parameter)
param_prov = DB.ParameterValueProvider(param_id)
param_equality = DB.FilterNumericGreaterOrEqual()  #greater than equality class

value_rule = DB.FilterDoubleRule(param_prov, param_equality, length_feet,
                                 1e-3 / 0.3048)  # tolerance of 1 mm
param_filter = DB.ElementParameterFilter(value_rule)

same_cat_elements = \
        DB.FilteredElementCollector(doc,curview.Id)\
          .OfCategory(DB.BuiltInCategory.OST_Walls)\
          .WhereElementIsNotElementType()\
          .WherePasses(param_filter)\
          .ToElements()

filered_elements = []

for sim_element in same_cat_elements: