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()
# get id of solid fill solid_fill = fill_patterns[0].Id # set colors color_true = Autodesk.Revit.DB.Color(177, 199, 56) color_true2 = Autodesk.Revit.DB.Color(126, 150, 56) color_false = Autodesk.Revit.DB.Color(200, 0, 0) color_false2 = Autodesk.Revit.DB.Color(128, 0, 0) color_none = Autodesk.Revit.DB.Color(128, 128, 128) color_none2 = Autodesk.Revit.DB.Color(50, 50, 50) # create graphical overrides ogs_true = OverrideGraphicSettings().SetProjectionFillColor(color_true) ogs_true.SetProjectionFillPatternId(solid_fill) ogs_true.SetSurfaceTransparency(10) ogs_true.SetProjectionLineColor(color_true2) ogs_false = OverrideGraphicSettings().SetProjectionFillColor(color_false) ogs_false.SetProjectionFillPatternId(solid_fill) ogs_false.SetSurfaceTransparency(0) ogs_false.SetProjectionLineColor(color_false2) ogs_none = OverrideGraphicSettings().SetProjectionFillColor(color_none) ogs_none.SetProjectionFillPatternId(solid_fill) ogs_none.SetSurfaceTransparency(40) ogs_none.SetProjectionLineColor(color_none2) # set up regex to compare levels "OKFF" "OKRD" etc. regex_lvl = re.compile('[A-Z]{4}')
color_da = Autodesk.Revit.DB.Color(3, 147, 188) color_da2 = Autodesk.Revit.DB.Color(0, 64, 128) color_d_da = Autodesk.Revit.DB.Color(3, 100, 188) color_d_da2 = Autodesk.Revit.DB.Color(0, 25, 128) color_none = Autodesk.Revit.DB.Color(200, 0, 0) color_none2 = Autodesk.Revit.DB.Color(128, 0, 0) # create graphical overrides # try is here to deal with the api change from 2019 to 2020 # when rvt 2019 is completely deprecated with SMP, delete try statement # and use only except part as main operation try: ogs_d = OverrideGraphicSettings().SetProjectionFillColor(color_d) ogs_d.SetProjectionFillPatternId(solid_fill) except: ogs_d = OverrideGraphicSettings().SetSurfaceForegroundPatternColor(color_d) ogs_d.SetSurfaceForegroundPatternId(solid_fill) ogs_d.SetSurfaceTransparency(10) ogs_d.SetProjectionLineColor(color_d2) try: ogs_da = OverrideGraphicSettings().SetProjectionFillColor(color_da) ogs_da.SetProjectionFillPatternId(solid_fill) except: ogs_da = OverrideGraphicSettings().SetSurfaceForegroundPatternColor( color_da) ogs_da.SetSurfaceForegroundPatternId(solid_fill) ogs_da.SetSurfaceTransparency(10) ogs_da.SetProjectionLineColor(color_da2)
filter_id = str( [i.Id for i in all_filters if i.Name == filter_name][0]) view.SetFilterVisibility(ElementId(int(filter_id)), 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(
for view in views: # 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 фильтра', 'Имя фильтра', 'Видимость', 'Проекция. Линии. Вес', 'Проекция. Линии. Цвет', 'Проекция. Линии. Образец', 'Проекция. Штриховки. Видимость', 'Проекция. Штриховки. Образец', 'Проекция. Штриховки. Цвет', 'Проекция. Прозрачность', 'Разрез. Линии. Вес', 'Разрез. Линии. Цвет', 'Разрез. Линии. Образец', 'Разрез. Штриховки. Видимость', 'Разрез. Штриховки. Образец', 'Разрез. Штриховки. Цвет', 'Полутона', 'Статус' ]
color_ast = Autodesk.Revit.DB.Color(177,199,56) color_ast2 = Autodesk.Revit.DB.Color(126,150,56) color_ist = Autodesk.Revit.DB.Color(3,147,188) color_ist2 = Autodesk.Revit.DB.Color(0,64,128) color_none = Autodesk.Revit.DB.Color(200,0,0) color_none2 = Autodesk.Revit.DB.Color(128,0,0) # create graphical overrides # try is here to deal with the api change from 2019 to 2020 # when rvt 2019 is completely deprecated with SMP, delete try statement # and use only except part as main operation try: ogs_ast = OverrideGraphicSettings().SetProjectionFillColor(color_ast) ogs_ast.SetProjectionFillPatternId(solid_fill) except: ogs_ast = OverrideGraphicSettings().SetSurfaceForegroundPatternColor(color_ast) ogs_ast.SetSurfaceForegroundPatternId(solid_fill) ogs_ast.SetSurfaceTransparency(10) ogs_ast.SetProjectionLineColor(color_ast2) try: ogs_ist = OverrideGraphicSettings().SetProjectionFillColor(color_ist) ogs_ist.SetProjectionFillPatternId(solid_fill) except: ogs_ist = OverrideGraphicSettings().SetSurfaceForegroundPatternColor(color_ist) ogs_ist.SetSurfaceForegroundPatternId(solid_fill) ogs_ist.SetSurfaceTransparency(10) ogs_ist.SetProjectionLineColor(color_ist2)
color_ba = Autodesk.Revit.DB.Color(3, 147, 188) color_ba2 = Autodesk.Revit.DB.Color(0, 64, 128) color_gd_ba = Autodesk.Revit.DB.Color(3, 100, 188) color_gd_ba2 = Autodesk.Revit.DB.Color(0, 25, 128) color_none = Autodesk.Revit.DB.Color(200, 0, 0) color_none2 = Autodesk.Revit.DB.Color(128, 0, 0) # create graphical overrides # try is here to deal with the api change from 2019 to 2020 # when rvt 2019 is completely deprecated with SMP, delete try statement # and use only except part as main operation try: ogs_gd = OverrideGraphicSettings().SetProjectionFillColor(color_gd) ogs_gd.SetProjectionFillPatternId(solid_fill) except: ogs_gd = OverrideGraphicSettings().SetSurfaceForegroundPatternColor( color_gd) ogs_gd.SetSurfaceForegroundPatternId(solid_fill) ogs_gd.SetSurfaceTransparency(10) ogs_gd.SetProjectionLineColor(color_gd2) try: ogs_ba = OverrideGraphicSettings().SetProjectionFillColor(color_ba) ogs_ba.SetProjectionFillPatternId(solid_fill) except: ogs_ba = OverrideGraphicSettings().SetSurfaceForegroundPatternColor( color_ba) ogs_ba.SetSurfaceForegroundPatternId(solid_fill) ogs_ba.SetSurfaceTransparency(10)
if ui_select == 1: wall_constraint = Bip.WALL_TOP_OFFSET column_constraint = Bip.FAMILY_TOP_LEVEL_OFFSET_PARAM # process elements GetElemProps0(struct_elems0) GetElemProps1(struct_elems1) # create colors color_att = Autodesk.Revit.DB.Color(236, 77, 0) color_att2 = Autodesk.Revit.DB.Color(153, 51, 0) # create overrides try: ogs_att = OverrideGraphicSettings().SetProjectionFillColor(color_att) ogs_att.SetProjectionFillPatternId(solid_fill) except: ogs_att = OverrideGraphicSettings().SetSurfaceForegroundPatternColor( color_att) ogs_att.SetSurfaceForegroundPatternId(solid_fill) ogs_att.SetSurfaceTransparency(10) ogs_att.SetProjectionLineColor(color_att2) #get unique offsets offsets = [] for elem in elem_info: offsets.append(elem.offset) unique_offsets = set(offsets) #get hsv color range colors_hsv = []