Community
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
So, if I understand correctly, we can narrow down this issue to a bare minimum, can we? Would the following be a valid formulation of the problem you face?
Connector.CanBeHidden returns true for 2024 as well.
Missed to add it, sorry for that. Edited it now.
Can't find what you're looking for? Ask the community or share your knowledge.