Temporary Unhide section line no matter why it is hidden

Hello Dynamo friends :slight_smile:

Is there any way to force unhide an element?

I want to temporary unhide a section line.
This section line could be hidden by filters that have multiple conditions and parameters they aim at. It also could be hidden by the “hide in scales coarser than” setting, or it could be hidden with “element hide”, etc…

Do I have to check all different potential hiding methods, or is there an easier way that lets me just “force unhide” something?

Happy abou any advice regarding that topic :slight_smile:

Yes.

As an alternative, you could draw a new annotation element at that location, or you could use Dynamo’s temporary geometry display to show where things are. Neither allows direct interaction with the section after the fact though, so you may want to set it as the active selection as well.

2 Likes

This is probably what you want. Unless it’s hidden at the instance level to begin with, you won’t be able to “unhide” a specific instance only. You’re better off temporarily displaying something to represent that element.

1 Like

Jacob and Nick crushing my hopes and dreams :sweat_smile:

Hoping for a magical api method that will solve my problem, i gave too little context to what i want to do (as always). So here it is.

I have section views on a sheet. Every section has a duplicate view, they are placed on top of each other. These duplicate views are what i want to get visible in a floor plan as section lines. So a visual representation is not enough for my use case, the section lines should be full modifyable.

OK, its not too hard to check if the section line has been hidden maually. And i can just remove all filters and as soon as all section lines are visible i can hide all the lines i dont want to see…I´d pretty much start by just making everything visible…but it looks like the “Hide at scales coarser than” is a problem because it is only read only?! So no way to get these section lines visible with the api :grimacing:

You don’t seem to have a repeating process (and if you do then it is likely best to build an entire new workflow), so why not just bulk select them with Dynamo, and manually change them all in the properties pallet?

1 Like

Because I would have never thought of that :smiley: problem solved!

1 Like

Code is running, this is my workflow:

Get section lines in active view.
Get all views in the project that are placed on the same sheets as these section lines:

def collect_related_views(current_view):
    collector = DB.FilteredElementCollector(revit.doc, current_view.Id)
    section_lines = collector.OfCategory(DB.BuiltInCategory.OST_Viewers).WhereElementIsNotElementType().ToElements()
    sections = get_view_from_section_line(section_lines)
    viewports = get_viewport_from_section_line(sections)
    related_sheets = {vp.SheetId for vp in viewports if vp.SheetId != DB.ElementId.InvalidElementId}
    related_views = {revit.doc.GetElement(vp_id).ViewId.IntegerValue for sheet_id in related_sheets for vp_id in revit.doc.GetElement(sheet_id).GetAllViewports()}
    return related_views

unhide all section lines by setting all view filters that are of category section to visible:

def toggle_filter_visibility(view, visibility):
    view_filters = view.GetFilters()
    sections_category_id = DB.ElementId(DB.BuiltInCategory.OST_Sections)

    for filter_id in view_filters:
        filter_elem = revit.doc.GetElement(filter_id)
        categories = filter_elem.GetCategories()
        if sections_category_id in categories:
            view.SetFilterVisibility(filter_id, visibility)

    revit.doc.Regenerate()

Use HideElementTemporary to hide all unrelated section lines in the temporary hide mode:

def hide_unrelated_sectionlines(current_view, related_views):
    collector = DB.FilteredElementCollector(revit.doc, current_view.Id)
    section_lines = collector.OfCategory(DB.BuiltInCategory.OST_Viewers).WhereElementIsNotElementType().ToElements()
    sections = get_view_from_section_line(section_lines)
    for section_line, view in zip(section_lines, sections):
        if view and view.Id.IntegerValue not in related_views:
            current_view.HideElementTemporary(section_line.Id)

and later:

active_view.TemporaryViewModes.DeactivateAllModes()

Thanks for the help :slight_smile:

1 Like

Found a code snippet from the building coder where i saw setting the SectionCoarserScalePulldownMetric Property should work, and it does :slight_smile:

t = Transaction(doc, "Set Coarser Scale")
t.Start()

active_view = doc.ActiveView

active_view.get_Parameter(BuiltInParameter.SECTION_COARSER_SCALE_PULLDOWN_METRIC).Set(1)

t.Commit()
1 Like