Example #1
0
def get_modelview_type():
    switch = CommandSwitchWindow(view_types_dict.keys()).pick_cmd_switch()
    if switch:
        return switch
    else:
        logger.debug('User cancelled.')
        sys.exit(0)
Example #2
0
def get_view_level():
    global selected_level
    if not selected_level:
        levels = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Levels) \
                                              .WhereElementIsNotElementType()         \
                                              .ToElements()
        levels_dict = {lvl.Name:lvl for lvl in levels}
        picked_level = CommandSwitchWindow(levels_dict.keys()).pick_cmd_switch()
        selected_level = levels_dict[picked_level]

    return selected_level
Example #3
0
    # add all elements as first set, for totals of all elements
    el_sets['All Selected Elements'].extend(element_list)

    # separate elements into sets based on their type
    for el in element_list:
        if hasattr(el ,'LineStyle'):
            el_sets[el.LineStyle.Name].append(el)
        else:
            tname = Element.Name.GetValue(doc.GetElement(el.GetTypeId()))
            el_sets[tname].append(el)

    return el_sets

# main -------------------------------------------------------------------------
# ask user to select an option
options = process_options(selection.elements)
selected_switch = \
    CommandSwitchWindow(sorted(options),
                        'Sum values of parameter:').pick_cmd_switch()

# Calculating totals for each set and printing results
if selected_switch:
    selected_option = options[selected_switch]
    if selected_option:
        for type_name, element_set in process_sets(selection.elements).items():
            type_name = type_name.replace('<', '&lt;').replace('>', '&gt;')
            out.print_md('### Totals for: {}'.format(type_name))
            output_param_total(element_set, selected_option)
            out.insert_divider()
Example #4
0
from Autodesk.Revit.DB import FilteredElementCollector, BuiltInCategory, Group, ElementId, Wall, Dimension
# noinspection PyUnresolvedReferences
from System.Collections.Generic import List

element_cats = {
    'Area Lines': BuiltInCategory.OST_AreaSchemeLines,
    'Doors': BuiltInCategory.OST_Doors,
    'Room Separation Lines': BuiltInCategory.OST_RoomSeparationLines,
    'Room Tags': None,
    'Model Groups': None,
    'Painted Elements': None,
    'Model Elements': None
}

selected_switch = CommandSwitchWindow(
    sorted(element_cats.keys()),
    'Temporarily isolate elements of type:').pick_cmd_switch()

if selected_switch:
    curview = uidoc.ActiveGraphicalView

    if selected_switch == 'Room Tags':
        roomtags = FilteredElementCollector(doc, curview.Id).OfCategory(
            BuiltInCategory.OST_RoomTags).WhereElementIsNotElementType(
            ).ToElementIds()
        rooms = FilteredElementCollector(doc, curview.Id).OfCategory(
            BuiltInCategory.OST_Rooms).WhereElementIsNotElementType(
            ).ToElementIds()

        allelements = []
        allelements.extend(rooms)
Example #5
0
        filteredlist = []
        for el in sellist:
            filteredlist.append(el.Id)
        uidoc.Selection.SetElementIds(List[ElementId](filteredlist))
    except:
        pass


selected_switch = CommandSwitchWindow(
    sorted([
        'Area',
        'Column',
        'Dimension',
        'Door',
        'Floor',
        'Framing',
        'Furniture',
        'Grid',
        'Rooms',
        'Room Tag',
        'Truss',
        'Wall',
        'Window',
        'Ceiling',
        'Section Box',
        'Elevation Mark',
        'Parking',
    ]), 'Pick only elements of type:').pick_cmd_switch()
if selected_switch is not '':
    pickbycategory(selected_switch)
Example #6
0
selected_switch = CommandSwitchWindow(
    sorted([
        'Graphic Styles',
        'Grids',
        'Line Patterns',
        'Line Styles',
        'Selected Line Coordinates',
        'Model / Detail / Sketch Lines',
        'Project Parameters',
        'Data Schemas',
        'Data Schema Entities',
        'Sketch Planes',
        'Views',
        'View Templates',
        'Viewports',
        'Viewport Types',
        'Family Symbols',
        'Levels',
        'Scope Boxes',
        'Areas',
        'Rooms',
        'External References',
        'Revisions',
        'Revision Clouds',
        'Sheets',
        'System Categories',
        'System Postable Commands',
        'Worksets',
    ]), 'List elements of type:').pick_cmd_switch()
Example #7
0
    'Viewports',
    'Viewport Types',
    'Family Symbols',
    'Levels',
    'Scope Boxes',
    'Areas',
    'Rooms',
    'External References',
    'Revisions',
    'Revision Clouds',
    'Sheets',
    'System Categories',
    'System Postable Commands',
    'Worksets',
]
sel_switch = CommandSwitchWindow(sorted(switches),
                                 'List elements of type:').pick_cmd_switch()

if sel_switch == 'Graphic Styles':
    cl = FilteredElementCollector(doc)
    gstyles = [i for i in cl.OfClass(GraphicsStyle).ToElements()]

    for gs in gstyles:
        if gs.GraphicsStyleCategory.Parent:
            parent = gs.GraphicsStyleCategory.Parent.Name
        else:
            parent = '---'
        if gs.GraphicsStyleCategory.GetHashCode() > 0:
            print('NAME: {0} CATEGORY:{2} PARENT: {3} ID: {1}'.format(
                gs.Name.ljust(50), gs.Id,
                gs.GraphicsStyleCategory.Name.ljust(50), parent.ljust(50)))
Example #8
0
    for param in el.ParametersMap:
        if _is_calculable_param(param):
            shared_params.add(param.Definition.Name)

    el_type = doc.GetElement(el.GetTypeId())
    if el_type and el_type.Id != ElementId.InvalidElementId:
        for type_param in el_type.ParametersMap:
            if _is_calculable_param(type_param):
                shared_type_params.add(type_param.Definition.Name)

# make a list of options from discovered parameters
options = list(shared_params.union(shared_type_params))
# options.extend(custom_calc_funcs.keys())

# ask user to select an option
selected_switch = CommandSwitchWindow(
    sorted(options), 'Sum values of parameter:').pick_cmd_switch()

total = 0

# process selection option and get the calculated total
if selected_switch:
    if selected_switch in custom_calc_funcs:
        total = custom_calc_funcs[selected_switch]()
    else:
        total = _calc_param_total(selected_switch)

    # figure out how to output the total
    if selected_switch in custom_output_formatters:
        custom_output_formatters[selected_switch](total)
    else:
        print("TOTAL {} OF ALL SELECTED ELEMENTS IS: {}".format(