示例#1
0
def run():

    # retrieve List color from excel file
    lcolor = [
        sheet.cell_value(row,
                         col2num("A") - 1) for row in range(1, sheet.nrows)
    ]

    # eval ele in list
    lcolor = map(eval_str, lcolor)

    # Filtered Element Collector family instance
    f_family_ins = FilteredElementCollector(doc).OfClass(FamilyInstance)

    # create dict key: id, value: family instaces
    dic_ele = dict_by_familyinstance(f_family_ins)

    # start index value
    index = 0

    # start transaction
    t = Transaction(doc, "Change Color Element")
    t.Start()

    for keyid in list(dic_ele.keys()):

        if index >= len(lcolor):
            index = 0

        # get index of color
        r, b, g = lcolor[index]

        # get color
        color_ele = Color(r, b, g)

        for ele_in in dic_ele[keyid]:
            # Settings to override display of elements in a view.
            override = OverrideGraphicSettings()

            # Sets the projection surface fill color
            override.SetProjectionFillColor(color_ele)

            # Sets the projection surface fill pattern
            override.SetProjectionFillPatternId(pattern_color())

            # Sets graphic overrides for an element in the view.
            view.SetElementOverrides(ele_in.Id, override)

        index = index + 1
    # commit transaction
    t.Commit()
示例#2
0
                                         bool(int(visibility)))
                cfg = OverrideGraphicSettings()

                cfg.SetProjectionLineWeight(int(pro_line_weight)) if int(
                    pro_line_weight) > 0 else None  # noqa
                cfg.SetProjectionLineColor(col(pro_line_color)) if col(
                    pro_line_color) else None  # noqa
                cfg.SetProjectionLinePatternId(
                    line(pro_line_pattern_id)) if line(
                        pro_line_pattern_id) else None  # noqa
                cfg.SetProjectionFillPatternVisible(
                    bool(int(pro_fill_pattern_visible)))  # noqa
                cfg.SetProjectionFillPatternId(
                    fill(pro_fill_pattern_id)) if fill(
                        pro_fill_pattern_id) else None  # noqa
                cfg.SetProjectionFillColor(col(pro_fill_color)) if col(
                    pro_fill_color) else None  # noqa
                cfg.SetSurfaceTransparency(int(transparency))  # noqa
                cfg.SetCutLineWeight(int(cut_line_weight)) if int(
                    cut_line_weight) > 0 else None  # noqa
                cfg.SetCutLineColor(col(cut_line_color)) if col(
                    cut_line_color) else None  # noqa
                cfg.SetCutLinePatternId(line(cut_line_pattern_id)) if line(
                    cut_line_pattern_id) else None  # noqa
                cfg.SetCutFillPatternVisible(
                    bool(int(cut_fill_pattern_visible)))  # noqa
                cfg.SetCutFillPatternId(fill(cut_fill_pattern_id)) if fill(
                    cut_fill_pattern_id) else None  # noqa
                cfg.SetCutFillColor(col(cut_fill_color)) if col(
                    cut_fill_color) else None  # noqa
                cfg.SetHalftone(bool(int(halftone)))  # noqa
    # view_filters = [doc.GetElement(ElementId(i)) for i in [1187542, 1189543, 1189548, ]]
    for elid, pat in [
        (1187542, 'ADSK_Накрест косая_2мм'),
        (1189543, 'General_Honeycomb'),
        (1189548, 'STARS'),
    ]:
        # print(view.Name)
        filt = doc.GetElement(ElementId(elid))
        # print(filt.Name)
        cfg = OverrideGraphicSettings()
        # cfg.SetProjectionLineWeight(              int(current_pro_line_weight)           ) if      int(current_pro_line_weight)     > 0 else None  # noqa
        # cfg.SetProjectionLineColor(               col(current_pro_line_color)            ) if      col(current_pro_line_color)          else None  # noqa
        # cfg.SetProjectionLinePatternId(          line(current_pro_line_pattern_id)       ) if     line(current_pro_line_pattern_id)     else None  # noqa
        # cfg.SetProjectionFillPatternVisible( bool(int(current_pro_fill_pattern_visible)) )                                                         # noqa
        cfg.SetProjectionFillPatternId(fill(pat))
        cfg.SetProjectionFillColor(col('192 192 192'))
        view.SetFilterOverrides(ElementId(elid), cfg)

# data.append(['---' for i in range(20)] + [len([i for i in data if i[20] != ''])])

columns = [
    'Id вида', 'Тип вида', 'Имя вида', 'Id фильтра', 'Имя фильтра',
    'Видимость', 'Проекция. Линии. Вес', 'Проекция. Линии. Цвет',
    'Проекция. Линии. Образец', 'Проекция. Штриховки. Видимость',
    'Проекция. Штриховки. Образец', 'Проекция. Штриховки. Цвет',
    'Проекция. Прозрачность', 'Разрез. Линии. Вес', 'Разрез. Линии. Цвет',
    'Разрез. Линии. Образец', 'Разрез. Штриховки. Видимость',
    'Разрез. Штриховки. Образец', 'Разрез. Штриховки. Цвет', 'Полутона',
    'Статус'
]