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 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)
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) ogs_manual = OverrideGraphicSettings().SetSurfaceForegroundPatternColor( color_manual) ogs_manual.SetSurfaceForegroundPatternId(solid_fill)
# 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_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) try: ogs_d_da = OverrideGraphicSettings().SetProjectionFillColor(color_d_da) ogs_d_da.SetProjectionFillPatternId(solid_fill) except:
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()
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_ad = OverrideGraphicSettings().SetProjectionFillColor(color_ad) ogs_ad.SetProjectionFillPatternId(solid_fill) except: ogs_ad = OverrideGraphicSettings().SetSurfaceForegroundPatternColor(color_ad) ogs_ad.SetSurfaceForegroundPatternId(solid_fill) ogs_ad.SetSurfaceTransparency(10) ogs_ad.SetProjectionLineColor(color_ad2) try: ogs_db = OverrideGraphicSettings().SetProjectionFillColor(color_db) ogs_db.SetProjectionFillPatternId(solid_fill) except: ogs_db = OverrideGraphicSettings().SetSurfaceForegroundPatternColor(color_db) ogs_db.SetSurfaceForegroundPatternId(solid_fill) ogs_db.SetSurfaceTransparency(10) ogs_db.SetProjectionLineColor(color_db2) try: ogs_none = OverrideGraphicSettings().SetProjectionFillColor(color_none) ogs_none.SetProjectionFillPatternId(solid_fill) except: ogs_none = OverrideGraphicSettings().SetSurfaceForegroundPatternColor(color_none)
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()
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 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(
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) try: ogs_none = OverrideGraphicSettings().SetProjectionFillColor(color_none) ogs_none.SetProjectionFillPatternId(solid_fill) except: ogs_none = OverrideGraphicSettings().SetSurfaceForegroundPatternColor(color_none)
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) ogs_ba.SetProjectionLineColor(color_ba2) try: ogs_gd_ba = OverrideGraphicSettings().SetProjectionFillColor(color_gd_ba) ogs_gd_ba.SetProjectionFillPatternId(solid_fill) except:
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 = [] for i in [x * 0.01 for x in range(0, 100, (99 / (len(unique_offsets) - 1)))]: colors_hsv.append((i, 0.5, 0.9)) def hsv2rgb(h, s, v):