def override_graphics_line(doc, view, line, line_color=None, line_pattern_id=None, lineweight=None): """Function to ovverride given region with the override settings. :param doc: Revit Document :param line: DetailCurve to apply OverrideGraphicsSettings :param fg_pattern_id: Foreground - Pattern id :param fg_color: Foreground - Colour :param bg_pattern_id: Background - Pattern id :param bg_color: Background - Colour :return: None """ try: override_settings = OverrideGraphicSettings() # LINE if line_color: override_settings.SetProjectionLineColor(line_color) if line_pattern_id: override_settings.SetProjectionLinePatternId(line_pattern_id) if lineweight: override_settings.SetProjectionLineWeight(lineweight) view.SetElementOverrides(line.Id, override_settings) except: import traceback print(traceback.format_exc())
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()
def get_source_style(element_id): # get style of selected element from_style = doc.ActiveView.GetElementOverrides(element_id) # make a new clean element style src_style = OverrideGraphicSettings() # setup a new style per config and borrow from the selected element's style setup_style_per_config(from_style, src_style) return src_style
def halftone(tags): """Halftone Tag Function""" graphic_halftone = OverrideGraphicSettings().SetHalftone(True) count = 0 for t in tags: try: t.tag_view.SetElementOverrides(t.ID, graphic_halftone) count += 1 except: pass return count
categories = [] for e in selection: elem = doc.GetElement(e.ElementId) cat = doc.GetElement(e.ElementId).Category.Name # Check if element is group or assembly to extract elements if cat == "Assemblies" or cat == "Model Groups": ids = elem.GetMemberIds() # Get elements category inside groups or assemblies for id in ids: catsub = doc.GetElement(id).Category.Name categories.append(catsub) else: categories.append(cat) # Override tranparency settings overtransparency = OverrideGraphicSettings() overtransparency.SetSurfaceTransparency(50) # Create a individual transaction t = Transaction(doc, "Override category visibility") # Start individual transaction t.Start() # Override all categories transparency for c in docCat: if c.Name not in categories: try: activeView.SetCategoryOverrides(c.Id, overtransparency) except: pass
if el: el = el[0] par = el.GetParameters("Рзм.Диаметр") if el.GetParameters("Рзм.Диаметр"): par = el.GetParameters("Рзм.Диаметр")[0] elif doc.GetElement(el.GetTypeId()).GetParameters("Рзм.Диаметр"): par = doc.GetElement(el.GetTypeId()).GetParameters("Рзм.Диаметр")[0] if par: diam = to_mm(par.AsDouble()) sel_color = ColorSelectionDialog() if sel_color.Show() == ItemSelectionDialogResult.Confirmed: color = sel_color.SelectedColor filter = create_filter(diam, par) active_view = doc.ActiveView if active_view.IsFilterApplied(filter.Id): active_view.RemoveFilter(filter.Id) over = OverrideGraphicSettings() over.SetProjectionLineColor(color) over.SetCutLineColor(color) active_view.AddFilter(filter.Id) active_view.SetFilterOverrides(filter.Id, over) if active_view.ViewTemplateId != ElementId.InvalidElementId and active_view.ViewTemplateId: template = active_view.ViewTemplateId if template.IsFilterApplied(filter.Id): template.RemoveFilter(filter.Id) doc.GetElement(active_view.ViewTemplateId).AddFilter(filter.Id) doc.GetElement(active_view.ViewTemplateId).SetFilterOverrides( filter.Id, over) t.Commit()
def hsv2rgb(h, s, v): return tuple(round(i * 255) for i in colorsys.hsv_to_rgb(h, s, v)) colors_rgb = [] for color in colors_hsv: colors_rgb.append(hsv2rgb(color[0], color[1], color[2])) # print(colors_rgb) do_color = dict(zip(design_options, colors_rgb)) # print(do_color) # create graphical overrides ogs = OverrideGraphicSettings().SetSurfaceForegroundPatternId(solid_fill) ogs.SetCutForegroundPatternId(solid_fill) # entering a transaction to modify the revit model database # start transaction tx = Transaction(doc, "Visualize Design Options") tx.Start() for element in elements: try: color = do_color.get( element.LookupParameter("Entwurfsoption").AsString()) # print(color) color_revit = Autodesk.Revit.DB.Color(color[0], color[1], color[2]) # print(color_revit) # ogs.SetProjectionLineColor(color_revit)
def get_overidegraphics(color): org = OverrideGraphicSettings() org.SetSurfaceBackgroundPatternVisible(False) org.SetSurfaceForegroundPatternColor(color) org.SetSurfaceForegroundPatternId(ElementId(3)) return org
from Autodesk.Revit.DB import OverrideGraphicSettings from Autodesk.Revit.DB import View from Autodesk.Revit.DB import TemporaryViewMode import Autodesk # reference the current open revit model to work with: doc = __revit__.ActiveUIDocument.Document view = doc.ActiveView # connect to revit model elements via FilteredElementCollector elements = filter(None, Fec(doc, doc.ActiveView.Id).ToElements()) ogs = OverrideGraphicSettings().SetSurfaceTransparency(0) # entering a transaction to modify the revit model database # start transaction tx = Transaction(doc, "clear graphic overrides") tx.Start() doc.ActiveView.DisableTemporaryViewMode(TemporaryViewMode.TemporaryHideIsolate) for element in elements: doc.ActiveView.SetElementOverrides((element.Id), ogs) # commit the changes to the revit model database # end transaction
# get id of solid fill solid_fill = fill_patterns[0].Id # set colors color_true = Autodesk.Revit.DB.Color(28, 144, 51) color_true2 = Autodesk.Revit.DB.Color(0, 100, 68) color_false = Autodesk.Revit.DB.Color(158, 28, 47) color_false2 = Autodesk.Revit.DB.Color(100, 26, 7) color_att = Autodesk.Revit.DB.Color(236, 77, 0) color_att2 = Autodesk.Revit.DB.Color(153, 51, 0) color_manual = Autodesk.Revit.DB.Color(36, 157, 151) color_manual2 = Autodesk.Revit.DB.Color(22, 95, 91) # create graphical overrides ogs_true = OverrideGraphicSettings().SetSurfaceForegroundPatternColor( color_true) ogs_true.SetSurfaceForegroundPatternId(solid_fill) ogs_true.SetSurfaceTransparency(10) ogs_true.SetProjectionLineColor(color_true2) ogs_false = OverrideGraphicSettings().SetSurfaceForegroundPatternColor( color_false) ogs_false.SetSurfaceForegroundPatternId(solid_fill) ogs_false.SetSurfaceTransparency(0) ogs_false.SetProjectionLineColor(color_false2) ogs_att = OverrideGraphicSettings().SetSurfaceForegroundPatternColor(color_att) ogs_att.SetSurfaceForegroundPatternId(solid_fill) ogs_att.SetSurfaceTransparency(10) ogs_att.SetProjectionLineColor(color_att2)
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. See this link for a copy of the GNU General Public License protecting this package. https://github.com/eirannejad/pyRevit/blob/master/LICENSE """ __doc__ = 'Sets the element graphic override to Solid projection lines for the selected elements.' __window__.Close() from Autodesk.Revit.DB import Transaction, OverrideGraphicSettings, LinePatternElement doc = __revit__.ActiveUIDocument.Document selection = [ doc.GetElement(elId) for elId in __revit__.ActiveUIDocument.Selection.GetElementIds() ] with Transaction(doc, "Set Element to Solid Projection Line Pattern") as t: t.Start() for el in selection: if el.ViewSpecific: ogs = OverrideGraphicSettings() ogs.SetProjectionLinePatternId( LinePatternElement.GetSolidPatternId()) doc.ActiveView.SetElementOverrides(el.Id, ogs) t.Commit()
def override_graphics_region(doc, view, region, fg_pattern_id, fg_color, bg_pattern_id, bg_color, line_color=None, line_pattern_id=None, lineweight=None): """Function to ovverride given region with the override settings. :param doc: Revit Document :param region: FilledRegion to apply OverrideGraphicsSettings :param fg_pattern_id: Foreground - Pattern id :param fg_color: Foreground - Colour :param bg_pattern_id: Background - Pattern id :param bg_color: Background - Colour :return: None """ try: override_settings = OverrideGraphicSettings() if fg_pattern_id != ElementId(-1): override_settings.SetSurfaceForegroundPatternId(fg_pattern_id) override_settings.SetSurfaceForegroundPatternColor(fg_color) else: override_settings.SetSurfaceForegroundPatternColor( Color(255, 255, 255)) if bg_pattern_id != ElementId(-1): override_settings.SetSurfaceBackgroundPatternId(bg_pattern_id) override_settings.SetSurfaceBackgroundPatternColor(bg_color) else: override_settings.SetSurfaceBackgroundPatternColor( Color(255, 255, 255)) # LINE if line_color: override_settings.SetProjectionLineColor(line_color) if line_pattern_id: override_settings.SetProjectionLinePatternId(line_pattern_id) if lineweight: override_settings.SetProjectionLineWeight(lineweight) view.SetElementOverrides(region.Id, override_settings) except: # DELETE REGIONS IF MODEL PATTERN IS USED ? doc.Delete(region.Id)
views = natural_sorted(views, key=lambda x: x.Name) views = sorted(views, key=lambda x: x.get_Parameter(BuiltInParameter.ELEM_TYPE_PARAM). AsValueString()) # data = [] 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 фильтра', 'Имя фильтра', 'Видимость', 'Проекция. Линии. Вес', 'Проекция. Линии. Цвет', 'Проекция. Линии. Образец', 'Проекция. Штриховки. Видимость', 'Проекция. Штриховки. Образец', 'Проекция. Штриховки. Цвет',
# set colors 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)
column_constraint = Bip.FAMILY_BASE_LEVEL_OFFSET_PARAM 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
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. See this link for a copy of the GNU General Public License protecting this package. https://github.com/eirannejad/pyRevit/blob/master/LICENSE """ __doc__ = 'Sets element graphic override to halftone on the selected elements. If any of the elements is a group, the script will apply the override to all its members.' __window__.Close() from Autodesk.Revit.DB import Transaction, OverrideGraphicSettings, Group doc = __revit__.ActiveUIDocument.Document selection = [ doc.GetElement(elId) for elId in __revit__.ActiveUIDocument.Selection.GetElementIds() ] with Transaction(doc, 'Halftone Elements in View') as t: t.Start() for el in selection: if isinstance(el, Group): for mem in el.GetMemberIds(): selection.append(doc.GetElement(mem)) ogs = OverrideGraphicSettings() ogs.SetHalftone(True) # ogs.SetProjectionFillPatternVisible(False) doc.ActiveView.SetElementOverrides(el.Id, ogs) t.Commit()
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)
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. See this link for a copy of the GNU General Public License protecting this package. https://github.com/eirannejad/pyRevit/blob/master/LICENSE ''' __doc__ = 'Sets element graphic override to halftone on the selected elements. If any of the elements is a group, the script will apply the override to all its members.' __window__.Close() from Autodesk.Revit.DB import Transaction, OverrideGraphicSettings, Group doc = __revit__.ActiveUIDocument.Document selection = [ doc.GetElement(elId) for elId in __revit__.ActiveUIDocument.Selection.GetElementIds() ] with Transaction(doc, 'Halftone Elements in View') as t: t.Start() for el in selection: if isinstance(el, Group): for mem in el.GetMemberIds(): selection.append(doc.GetElement(mem)) ogs = OverrideGraphicSettings() ogs.SetHalftone(True) ogs.SetProjectionFillPatternVisible(False) doc.ActiveView.SetElementOverrides(el.Id, ogs) 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.
view.Name = view_name except Exception as e: print('view_name') print(view.Name) print(view_name) raise e view_id = view.Id view_symbol = view.get_Parameter( BuiltInParameter.ELEM_TYPE_PARAM).AsValueString() if filter_name: 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
This file is part of pyRevit repository at https://github.com/eirannejad/pyRevit pyRevit is a free set of scripts for Autodesk Revit: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. See this link for a copy of the GNU General Public License protecting this package. https://github.com/eirannejad/pyRevit/blob/master/LICENSE """ __doc__ = 'Resets element graphic override for the selected elements.' __window__.Close() from Autodesk.Revit.DB import Transaction, OverrideGraphicSettings uidoc = __revit__.ActiveUIDocument doc = __revit__.ActiveUIDocument.Document selection = __revit__.ActiveUIDocument.Selection.GetElementIds() with Transaction(doc, 'Reset Element Override') as t: t.Start() for elId in selection: ogs = OverrideGraphicSettings() doc.ActiveView.SetElementOverrides(elId, ogs) t.Commit()
GNU General Public License for more details. See this link for a copy of the GNU General Public License protecting this package. https://github.com/eirannejad/pyRevit/blob/master/LICENSE """ __doc__ = 'Sets the element graphic overrides to white projection color on the selected elements.' __window__.Close() from Autodesk.Revit.DB import Transaction, OverrideGraphicSettings, LinePatternElement, Group, Color uidoc = __revit__.ActiveUIDocument doc = __revit__.ActiveUIDocument.Document selection = [ doc.GetElement(elId) for elId in __revit__.ActiveUIDocument.Selection.GetElementIds() ] with Transaction(doc, 'Whiteout Selected Elements') as t: t.Start() for el in selection: if el.ViewSpecific: continue elif isinstance(el, Group): for mem in el.GetMemberIds(): selection.append(doc.GetElement(mem)) ogs = OverrideGraphicSettings() ogs.SetProjectionLineColor(Color(255, 255, 255)) doc.ActiveView.SetElementOverrides(el.Id, ogs) t.Commit()