How to hide elements in view?

This used to do the job, but doesn’t seem to work in Revit 2019. Any thoughts why?
Update:
This has been solved with updated code
https://forum.dynamobim.com/t/hide-and-unhide-elements-in-view/29825