Message 1 of 3
view.HideElements() does not work in Revit 2024
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
HideElements() method doesn't work in Revit 2024 (and 2023).
I am trying to hide connector in the family.
Hiding elements temporary is not a solution for me, because it will be visible again after closing and opening family again.
I attached a family and here is a code sample.
This was working in 2022.
Any news about this issue?
public class Command : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
Document document = commandData.Application.ActiveUIDocument.Document;
View activeView = document.ActiveView;
FilteredElementCollector collector = new FilteredElementCollector(document, activeView.Id);
List<ElementId> connectors = collector
.OfCategory(BuiltInCategory.OST_ConnectorElem)
.WhereElementIsNotElementType()
.ToElementIds()
.ToList();
Element connector = document.GetElement(connectors[0]);
using (Transaction transaction = new Transaction(document))
{
transaction.Start("Hide Connectors");
bool canBeHidden = connector.CanBeHidden(activeView);//returns true in 2022, 2023 and 2024 version
if (connectors.Count > 0)
activeView.HideElements(connectors);
transaction.Commit();
}
return Result.Succeeded;
}
}
Regards,
Nataša