def load_from_definition_file_click(self, sender, e):
        try:
            groups = rsparam.get_paramgroups(
                self.definition_file_path, encoding="utf-16"
            )
            available_groups = sorted(groups, key=lambda x: locale.strxfrm(x.name))
        except IOError:
            self.invalid_definition_file()
            return
        # available_groups = sorted(definition_file.Groups, key=lambda x: locale.strxfrm(x.Name))
        selected_groups = SelectFromList.show(
            available_groups,
            "Select groups",
            400,
            300,
            name_attr="name",
            multiselect=True,
        )
        logger.debug("{} result = {}".format(SelectFromList.__name__, selected_groups))

        if selected_groups is None:
            return

        try:
            for parameter in rsparam.get_params(
                self.definition_file_path, encoding="utf-16"
            ):
                if parameter.group in selected_groups:
                    self.data_grid_content.Add(SharedParameter.from_rsparam(parameter))
        except LookupError as e:
            logger.info(e)
Exemple #2
0
    def load_from_definition_file_click(self, sender, e):
        definition_file = self.definition_file
        if not definition_file:
            self.invalid_definition_file()
            return

        available_groups = sorted(
            [group.Name for group in definition_file.Groups],
            key=cmp_to_key(locale.strcoll))
        selected_groups = SelectFromList.show(available_groups,
                                              "Select groups", 400, 300)
        logger.debug("{} result = {}".format(SelectFromList.__name__,
                                             selected_groups))
        if selected_groups is None:
            return
        else:
            groups = [
                definition_file.Groups[group] for group in selected_groups
            ]
        try:
            for parameter in SharedParameter.read_from_definition_file(
                    definition_groups=groups):
                self.data_grid_content.Add(parameter)
        except LookupError as e:
            logger.info(e)
Exemple #3
0
def select_levels_dialog(elements_all, name="parent object"):
    selected = SelectFromList.show(elements_all,
                                   name_attr='Name',
                                   title='Select %s to check' % name,
                                   width=300,
                                   button_name='Select',
                                   multiselect=True)
    return selected
def select_types(sysfam): #list alltypes
    selected_types = SelectFromList.show(sorted([textnotetypeoption(x) for x in sysfam], 
                                                    key= lambda x: x.name),
                                               title='FamilyTYPES: ',
                                               button_name='DELETE PERMANENTLY from PROJECT',
                                               width=800,
                                               height=850,
                                               multiselect=True,
                                               filterfunc=None)
    return selected_types										   										   
def select_template(list):
    selected_types = SelectFromList.show(sorted(
        [textnotetypeoption(x) for x in list], key=lambda x: x.name),
                                         title="Select SystemFamilyTypes",
                                         button_name="Select",
                                         width=500,
                                         multiselect=True,
                                         filterfunc=None)

    return selected_types
Exemple #6
0
def select_type(typelist):

    selected_types = SelectFromList.show(
        sorted([textnotetypeoption(x) for x in typelist],
               key=lambda x: x.name),
        title="Select SystemFamilyTypes",
        button_name="DELETE PERMANENTLY from PROJECT",
        width=600,
        multiselect=True,
        filterfunc=None)

    return selected_types
Exemple #7
0
    def select_parameters(self):
        parameters_dict = self.get_selection_parameters(self.selection)
        parameters_editable = self.filter_editable(parameters_dict)

        options = []
        for param_id, param in parameters_editable.items():
            cb = CheckBoxParameter(param)
            options.append(cb)

        selected = SelectFromList.show(options, title='Parameter to replace', width=300,
                                       button_name='OK')

        return selected
Exemple #8
0
    def load_from_definition_file_click(self, sender, e):
        definition_file = self.definition_file
        if not definition_file:
            self.invalid_definition_file()
            return

        available_groups = sorted(definition_file.Groups, key=lambda x: locale.strxfrm(x.Name))
        selected_groups = SelectFromList.show(
            available_groups, "Select groups", 400, 300, name_attr="Name", multiselect=True)
        logger.debug("{} result = {}".format(SelectFromList.__name__, selected_groups))
        if selected_groups is None:
            return

        try:
            for parameter in SharedParameter.read_from_definition_file(definition_groups=selected_groups):
                self.data_grid_content.Add(parameter)
        except LookupError as e:
            logger.info(e)
Exemple #9
0
linePoints = []


def fuzzyMatch(a, b, precision):
    return abs(a - b) <= precision


options = [2000, 3000, 4000, 5000, 6000]

########
## need to handle sloping pipes!!!

# shows the form and returns the selected options
selected_options = SelectFromList.show(
    options,
    title='Select Height of High level Threshold for Pipes (mm from floor)',
    width=800,
    height=500,
    multiselect=False)

highLevelThreshold = selected_options[0]

t = Transaction(doc, 'Pipe Levels')

t.Start()

for pipe in pipes:

    line = pipe.Location.Curve

    curves.append(line)
Exemple #10
0
def main():
    cl = FilteredElementCollector(doc)
    levels_all = cl.OfCategory(BuiltInCategory.OST_Levels
                               ).WhereElementIsNotElementType().ToElements()

    options = []
    for l in levels_all:
        cb = CheckBoxLevel(l)
        options.append(cb)

    if len(options) == 0:
        print("Levels wasn't found")
        return

    selected1 = SelectFromList.show(options,
                                    title='Select levels to delete',
                                    width=300,
                                    button_name='OK',
                                    multiselect=True)
    selected_levels1 = [c.level for c in selected1 if c.state == True]

    if not selected_levels1:
        print("Nothing selected")
        return

    options = [c for c in selected1 if c.state != True]

    if len(options) == 0:
        print("You selected all levels")
        return

    selected2 = SelectFromList.show(options,
                                    title='Select target level',
                                    width=300,
                                    button_name='OK')
    if not selected2:
        print("Nothing selected")
        return

    selected_levels2 = [c.level for c in selected2]
    target_level = selected_levels2[0]
    errors = set()
    changed = set()
    for l in selected_levels1:
        objects_to_change = []

        t = Transaction(doc, "Check level " + l.Name)
        t.Start()
        elements = doc.Delete(l.Id)
        t.RollBack()

        errors_, changed_ = LevelChangePreselected(elements, target_level.Id)

        errors = errors.union(set(errors_))
        changed = changed.union(set(changed_))

    if errors:
        logger.error("Errors")
        logger.error(",".join(list(errors)))

    if changed:
        print("\nChanged succesfully")
        print(",".join(list(changed)))
    else:
        logger.error("No object were changed")
    def __init__(self,
                 name,
                 ptype,
                 group=None,
                 guid=None,
                 description="",
                 modifiable=True,
                 visible=True,
                 new=True):
        # type: (str, ParameterType or str, str, Guid or None, str, bool, bool, bool) -> None

        self.name = name
        self.description = description
        if group:
            self.group = group
        else:
            self.group = "pyrevitmep"

        true_tuple = (True, "", None, "True", "Yes", "Oui", 1, "1")

        if modifiable in true_tuple:
            self.modifiable = True
        else:
            self.modifiable = False

        if visible in true_tuple:
            self.visible = True
        else:
            self.visible = False

        # Check if a Guid is given. If not a new one is created
        if not guid:
            self.guid = Guid.NewGuid()
        elif not isinstance(guid, Guid):
            try:
                self.guid = Guid(guid)
            except SystemError:
                self.guid = Guid.NewGuid()
        else:
            self.guid = guid

        # Check if given parameter type is valid. If not user is prompted to choose one.
        if isinstance(ptype, ParameterType):
            self.type = ptype
        else:
            try:
                self.type = getattr(ParameterType, ptype)
            except AttributeError:
                self.type = ptype
                while not isinstance(self.type, ParameterType):
                    self.type = SelectFromList.show(
                        PType.enum_generator(),
                        "Parameter {} ParameterType: {} not valid. Please select a parameter type"
                        .format(name, ptype))

        self.initial_values = {}
        if new is True:
            self.new = new
        else:
            self.new = False
            self.initial_values_update()

        self.changed = False
Exemple #12
0
def main():
    active_view = get_active_view()
    if not active_view:
        logger.warning('Activate a view to copy')
        return

    logger.info('Source view selected: %s id%s' % (active_view.Name, active_view.Id.ToString()))

    """
    Filters selection
    """
    active_template_filters_ch = get_view_filters(doc, active_view)

    sel_set = read_checkboxes_state()
    vt_list = get_view_templates(doc, sel_set=sel_set)

    if not vt_list:
        logger.warning('Project has no view templates')
        return

    if not active_template_filters_ch:
        logger.warning('Active view has no filter overrides')
        return

    filter_checkboxes = SelectFromList.show(active_template_filters_ch, name_attr='Name',
                                            title='Select filters to copy',
                                            button_name='Select filters', multiselect=True)
    filter_checkboxes_sel = []

    # Select filters from active view
    for checkbox in filter_checkboxes:
        if checkbox:
            filter_checkboxes_sel.append(checkbox)

    if not filter_checkboxes_sel:
        return

    """
    Target view templates selection
    """
    view_checkboxes = SelectFromList.show(vt_list, name_attr='Name', title='Select templates to apply filters',
                                          button_name='Apply filters to templates', multiselect=True)
    view_checkboxes_sel = []

    # Select view templates to copy
    for checkbox in view_checkboxes:
        if checkbox:
            view_checkboxes_sel.append(checkbox)

    if not view_checkboxes_sel:
        return

    save_checkboxes_state(view_checkboxes_sel)

    # active_template = doc.GetElement(active_view.ViewTemplateId)

    t = Transaction(doc)
    t.Start(__title__)

    for vt in view_checkboxes_sel:
        if vt.Id == active_view.ViewTemplateId:
            logger.debug('Current template found')
            continue

        for f in filter_checkboxes_sel:
            try:
                vt.RemoveFilter(f.Id)
                logger.info('filter %s deleted from template %s' % (f.Id.IntegerValue.ToString(), vt.Name))
            except:
                pass

            try:
                fr = active_view.GetFilterOverrides(f.Id)
                vt.SetFilterOverrides(f.Id, fr)
            except Exception as e:
                logger.warning('filter %s was not aplied to view %s\n%s' % (f.Id.IntegerValue.ToString(),
                                                                            vt.Name, e))

    t.Commit()

    print("Completed")
Exemple #13
0
def main():
    global PURGE_RESULTS_CSV
    global START_TIME
    global PURGE_NOTUSED_FAMILIES

    # q = TaskDialog.Show(__title__, "Purge not used families?",
    #                             TaskDialogCommonButtons.Ok | TaskDialogCommonButtons.Cancel)
    # if str(q) == "Ok":
    #     PURGE_NOTUSED_FAMILIES = True

    purgers = Purgers()
    directory = create_directory(doc.Title)
    options = []
    selected_purgers = []

    for f in dir(purgers):
        func = purgers.__getattribute__(f)
        if type(func) == types.MethodType and f[0] != "_":

            opt = CheckBoxFunc(func, True)
            options.append(opt)
    if len(options) > 1:
        all_checkboxes = SelectFromList.show(options,
                                             title='Select cleaners to Purge',
                                             width=300,
                                             button_name='Purge!',
                                             multiselect=True)
        if all_checkboxes:
            selected_purgers = [
                c.func for c in all_checkboxes if c.state == True
            ]
    else:
        selected_purgers = [c.func for c in options]

    if len(selected_purgers) > 0:
        PURGED_COUNT = 0
        level = 0
        max_level = 99
        if doc.Title[-4:] == ".rfa":
            level = 1

        if __forceddebugmode__:
            max_level = 1

        START_TIME = time.time()
        print(directory)

        csv_line = [
            "Level", "Category", "Family name", "Size before", "Size after",
            "Size diff"
        ]

        for pk in selected_purgers:
            csv_line.append("Purged: " + str(pk.__name__))

        PURGE_RESULTS_CSV.append(csv_line)

        process_purge(doc,
                      selected_purgers,
                      level=level,
                      max_level=max_level,
                      directory=directory)
        output.set_title("%s - Write CSV" % (window_title, ))
        write_csv(directory)
        output.set_title("%s - Done" % (window_title, ))

        print("\n\nFinished")
        for r in PURGE_RESULTS.keys():
            c = PURGE_RESULTS[r]
            print("%s: %d" % (r, c))
            PURGED_COUNT += c
        print('\nTOTAL purged: %d' % PURGED_COUNT)
        print('SIZE DIFFERENCE: %.3f Mb' % PURGE_SIZES_SUM)

        print("\n\n--- %s ---" % (time_format(time_elapsed())))

        output.update_progress(100, 100)

    else:
        print("nothing selected")