Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

view.HideElements() does not work in Revit 2024

2 REPLIES 2
Reply
Message 1 of 3
natasa.jugovicNDJGN
410 Views, 2 Replies

view.HideElements() does not work in Revit 2024

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

 

2 REPLIES 2
Message 2 of 3

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 in Revit 2022 and Revit 2023, and false in Revit 2024.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 3

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.

Post to forums  

Rail Community


Autodesk Design & Make Report