def main(): """Main script.""" print("🐍 Running {fname} version {ver}...".format(fname=__name, ver=__version)) # STEP 0: Setup doc = __revit__.ActiveUIDocument.Document view = doc.ActiveView # STEP 1: Get all the tags in the view print("Getting all pipe tags from the view... ", end="") tags = db.FilteredElementCollector(doc, view.Id)\ .OfCategory(db.BuiltInCategory.OST_PipeTags)\ .WhereElementIsNotElementType()\ .ToElements() print("✔") print(" ➜ Found {num} tags in the current view.".format(num=len(tags))) # STEP 2: Filter for BHE_DE pipe riser tags print("Filtering for pipe riser tags... ", end="") riser_tags = [] for tag in tags: tag_type = doc.GetElement(tag.GetTypeId()) tag_family_name = tag_type.get_Parameter( db.BuiltInParameter.SYMBOL_FAMILY_NAME_PARAM).AsString() if tag_family_name == TAG_FAMILY_NAME: riser_tags.append(tag) print("✔") print(" ➜ Found {num} pipe riser tags in the current view.".format( num=len(riser_tags))) # STEP 3: Override tag color based on host system type color print("Recoloring all tags in the view based on host system color... ", end="") transaction = db.Transaction(doc) transaction.Start("{name} - v{ver}".format(name=__name, ver=__version)) try: for riser_tag in riser_tags: host = riser_tag.GetTaggedLocalElement() system = host.MEPSystem if system: system_type = doc.GetElement(system.GetTypeId()) color = system_type.LineColor override = db.OverrideGraphicSettings() view.SetElementOverrides(riser_tag.Id, override) # reset to default override.SetProjectionLineColor(color) view.SetElementOverrides(riser_tag.Id, override) except Exception as ex: print("\n✘ Exception:\n {ex}".format(ex=ex)) transaction.RollBack() return ui.Result.Failed else: transaction.Commit() print("✔\nDone. 😊") return ui.Result.Succeeded
clr.AddReference('RevitAPIUI') import Autodesk.Revit.DB as db import Autodesk.Revit.UI as ui clr.AddReference("System.Windows.Forms") import System.Windows.Forms as swf __name = "MarkAllClashes.py" __version = "1.0b" CLASH_COLOR = db.Color(255, 0, 0) # red CLASH_PATTERN_ID = db.ElementId(19) FADED_COLOR = db.Color(192, 192, 192) # light gray FADED_PATTERN_ID = CLASH_PATTERN_ID FADED_TRANSPARENCY = 50 clashing_overrides = db.OverrideGraphicSettings() clashing_overrides.SetProjectionLineColor(CLASH_COLOR) clashing_overrides.SetProjectionFillColor(CLASH_COLOR) clashing_overrides.SetProjectionFillPatternId(CLASH_PATTERN_ID) faded_overrides = db.OverrideGraphicSettings() faded_overrides.SetProjectionLineColor(FADED_COLOR) faded_overrides.SetProjectionFillColor(FADED_COLOR) faded_overrides.SetProjectionFillPatternId(FADED_PATTERN_ID) faded_overrides.SetSurfaceTransparency(FADED_TRANSPARENCY) def main(): """Main Function.""" print("Running {fname} version {ver}...".format(fname=__name, ver=__version))