Пример #1
0
__title__= "Remove\nunenclosed areas"
__doc__ = "Delete unenclosed areas from project"

from pyrevit import revit, DB, forms

# collect
areas = DB.FilteredElementCollector(revit.doc) \
        .OfCategory(DB.BuiltInCategory.OST_Areas) \
        .WhereElementIsNotElementType() \
        .ToElements()

forms.alert_ifnot(areas, "No Areas in model.", exitscript=True)

# get ids of areas with location and zero area
unenclosed_ids = [a.Id for a in areas if a.Location and a.Area == 0]

forms.alert_ifnot(unenclosed_ids, "All Areas are enclosed, good job", exitscript=True)

with revit.Transaction("Delete unenclosed areas"):

    deleted = [] # to keep track of elements deleted
    # remove unenclosed areas
    for upid in unenclosed_ids:
        revit.doc.Delete(upid)
        deleted.append(upid)

    # print result
    print("Removed {} unenclosed areas".format(len(deleted)))
Пример #2
0
    do_name = design_option.Name
    do_full_name = " : ".join([do_set, do_name])
    return do_full_name


def get_elements_by_do(do, doc=revit.doc):
    # quickly collect element belonging to a Design Option
    # quick filter
    do_filter = DB.ElementDesignOptionFilter(do.Id)
    # collect with Design Option filter
    do_el_list = DB.FilteredElementCollector(doc).WherePasses(do_filter).ToElements()
    return do_el_list


design_options = DB.FilteredElementCollector(revit.doc).OfClass(DB.DesignOption).ToElements()
forms.alert_ifnot(design_options, "No Design Options in model.", exitscript=True)
do_dict = {get_full_option_name(do) : do for do in design_options}

# construct rwp UI
components = [
    Label("Select Design Option:"),
    ComboBox(name="design_option", options = do_dict),
    Button("Select")]
form = FlexForm("Select Elements by Design Option", components)
form.show()
# assign chosen parameters
chosen_do = form.values["design_option"]

if not chosen_do:
    sys.exit()
Пример #3
0
    -2000123,  # Supports
    -2000173,  # curtain wall grids
    -2000171,  # curtain wall mullions
    -2000170,  # curtain panels
    -2000530,  # reference places
    -2000127,  # Balusters
    -2000947,  # Handrail
    -2000946,  # Top Rail
]

# get DO in model
design_options = DB.FilteredElementCollector(revit.doc).OfClass(
    DB.DesignOption).ToElements()
# exit in no DO
forms.alert_ifnot(design_options,
                  "No Design Options in model.",
                  exitscript=True)

# create dict of name and DO element
do_dict = {get_full_option_name(do): do for do in design_options}

for do_full_name, do in do_dict.items():
    # get all elements in DO
    all_in_do = get_elements_by_do(do)

    if all_in_do:

        element_categories = defaultdict(list)
        counter = 0
        # count elements by category
        for elem in all_in_do:
Пример #4
0
# construct rwp UI for Category
components = [
    Label("Pick Category:"),
    ComboBox(name="cat_combobox", options=cat_dict1, sorted=True),
    Button("Select")
]
form = FlexForm("Select", components)
form.show()

cat_name = ''

try:
    # assign chosen parameters
    cat_name = form.values["cat_combobox"].Name
except:
    forms.alert_ifnot(cat_name, "No selection", exitscript=True)

cat = GetBICFromCat(form.values["cat_combobox"])  #BuiltInCategory
param_dict1 = GetInstanceParameters(cat)

# construct rwp UI for Parameter and Prefix
components = [
    Label("Pick Parameter:"),
    ComboBox(name="param_combobox", options=param_dict1, sorted=True),
    Label("Prefix"),
    TextBox(
        name="prefix_box",
        Text="X00_",
        description=
        "Any prefix that you would like your numbering to have, such as 'ID_' for Interior Door"
    ),
Пример #5
0
__title__ = "Remove\nunplaced areas"
__doc__ = "Delete unplaced areas from project"

from pyrevit import revit, DB, forms

# collect
areas = DB.FilteredElementCollector(revit.doc) \
    .OfCategory(DB.BuiltInCategory.OST_Areas) \
    .WhereElementIsNotElementType() \
    .ToElements()

forms.alert_ifnot(areas, "No Areas in model.", exitscript=True)
# get ids of rooms with location equal to None
unplaced_ids = [a.Id for a in areas if a.Location is None]

forms.alert_ifnot(unplaced_ids,
                  "No unplaced Areas found, well done!",
                  exitscript=True)

with revit.Transaction("Remove Unplaced Areas"):
    deleted = []  # to keep track of elements deleted

    # remove unplaced rooms
    for upid in unplaced_ids:
        revit.doc.Delete(upid)
        deleted.append(upid)

    # print result
    print("Removed {0} unplaced areas".format(len(deleted)))
Пример #6
0
    DB.View).WhereElementIsNotElementType()

allowed_view_types = [
    DB.ViewType.FloorPlan, DB.ViewType.CeilingPlan, DB.ViewType.Elevation,
    DB.ViewType.ThreeD, DB.ViewType.DraftingView, DB.ViewType.AreaPlan,
    DB.ViewType.Section, DB.ViewType.Detail, DB.ViewType.Legend
]

views_with_filters = [
    view for view in col_views
    if view.ViewType in allowed_view_types and view.GetFilters()
]

# prep options
view_dict1 = {v.Name: v for v in views_with_filters}
forms.alert_ifnot(view_dict1, "No views with filters", exitscript=True)

# get all text styles to choose from
txt_types = DB.FilteredElementCollector(revit.doc).OfClass(DB.TextNoteType)
text_style_dict = {
    txt_t.get_Parameter(DB.BuiltInParameter.SYMBOL_NAME_PARAM).AsString():
    txt_t
    for txt_t in txt_types
}

# construct rwp UI
components = [
    Label("Pick Source View:"),
    ComboBox(name="view_combobox", options=view_dict1),
    Label("Pick Text Style"),
    ComboBox(name="textstyle_combobox", options=text_style_dict),
Пример #7
0
        elements.append(revit.doc.GetElement(ref))
    return elements


spfile = GetSharedParameterFile()
selection = revit.get_selection()

if len(selection) == 0:
    selection = GetElements(revit.uidoc.Selection.PickObjects(UI.Selection.ObjectType.Element, SymbolISelectionFilter()))

counter = 0
max_value = len(selection)

# print(str(max_value))

forms.alert_ifnot(max_value != 0, "No families were selected.", exitscript=True)

with ProgressBar(cancellable=True, step=1) as pb:
    for sel in selection:
        fam_ins = sel
        fam = fam_ins.Symbol.Family
        fam_doc = revit.doc.EditFamily(fam)

        AddRoomCalcPoint(fam_doc)

        # print("Is document modifiable? " + str(revit.doc.IsModifiable))
        fam = fam_doc.LoadFamily(revit.doc, FamilyLoaderOptionsHandler())
        counter += 1
        pb.update_progress(counter, max_value)

Пример #8
0
    -2000920,   # Landings
    -2000919,   # Stair runs
    -2000123,   # Supports
    -2000173,   # curtain wall grids
    -2000171,   # curtain wall mullions
    -2000170,   # curtain panels
    -2000530,   # reference places
    -2000127,   # Balusters
    -2000947,   # Handrail
    -2000946,   # Top Rail
]

# get DO in model
worksets = DB.FilteredWorksetCollector(revit.doc).OfKind(DB.WorksetKind.UserWorkset).ToWorksets()
# exit in no DO
forms.alert_ifnot(worksets, "No Worksets in model.", exitscript=True)

for w in worksets:
    # get all elements in DO
    all_in_w = get_elements_by_workset(w)

    if all_in_w:

        element_categories = defaultdict(list)
        counter = 0
        # count elements by category
        for elem in all_in_w:
            try:
                cat_name = elem.Category.Name
                cat_id = elem.Category.Id.IntegerValue
                if cat_id <0 and cat_id not in cat_ban_list:
Пример #9
0
from pyrevit import revit, DB, forms

# todo: to add multi view option

all_plan_regions = DB.FilteredElementCollector(revit.doc) \
    .OfCategory(DB.BuiltInCategory.OST_PlanRegion) \
    .WhereElementIsNotElementType()

# filter by owner id instead of active view to get hidden elements
plan_region_ids = []
if all_plan_regions:
    for pr in all_plan_regions:
        if pr.OwnerViewId.IntegerValue == revit.active_view.Id.IntegerValue:
            plan_region_ids.append(pr.Id)

forms.alert_ifnot(plan_region_ids, "No plan regions in view")
revit.get_selection().set_to(plan_region_ids)
Пример #10
0
    # returns only views of types compatible with scope box
    compatible_viewtypes = [
        DB.ViewType.FloorPlan, DB.ViewType.CeilingPlan,
        DB.ViewType.EngineeringPlan, DB.ViewType.AreaPlan, DB.ViewType.Section,
        DB.ViewType.Elevation, DB.ViewType.Detail, DB.ViewType.ThreeD
    ]
    filtered_views = [v for v in views if v.ViewType in compatible_viewtypes]
    return filtered_views


# collect all scope boxes
coll_scope = DB.FilteredElementCollector(revit.doc).OfCategory(
    DB.BuiltInCategory.OST_VolumeOfInterest).ToElementIds()

# exit if Scope Boxes found
forms.alert_ifnot(coll_scope, "No Scope Boxes in model.", exitscript=True)

# collect all views
coll_views = DB.FilteredElementCollector(revit.doc).OfClass(
    DB.View).WhereElementIsNotElementType()
# filter views compatible with scope boxes
compatible_views = filter_sb_viewtypes(coll_views)
# also collect levels and grids
cat_list = List[DB.BuiltInCategory](
    [DB.BuiltInCategory.OST_Levels, DB.BuiltInCategory.OST_Grids])
multi_cat_filter = DB.ElementMulticategoryFilter(cat_list)
coll_lvlgrids = DB.FilteredElementCollector(
    revit.doc).WherePasses(multi_cat_filter).WhereElementIsNotElementType()
# get a list of used scope boxes
used_sb = []
for view in compatible_views:
Пример #11
0
                          CheckBox)
import sys

# select all legend components in active view
view = revit.active_view
if view.ViewType != DB.ViewType.Legend:
    forms.alert("View is not a Legend View", exitscript=True)


legend_components = DB.FilteredElementCollector(revit.doc, view.Id) \
    .OfCategory(DB.BuiltInCategory.OST_LegendComponents) \
    .WhereElementIsNotElementType() \
    .ToElements()

forms.alert_ifnot(legend_components,
                  "No Legend Components in View",
                  exitscript=True)

# get all text styles to choose from
txt_types = DB.FilteredElementCollector(revit.doc).OfClass(DB.TextNoteType)
text_style_dict = {
    txt_t.get_Parameter(DB.BuiltInParameter.SYMBOL_NAME_PARAM).AsString():
    txt_t
    for txt_t in txt_types
}

# list positions for text placement
positions_list = [
    "Bottom Left", "Bottom Centre", "Bottom Right", "Top Left", "Top Centre",
    "Top Right"
]