Reveal Hidden Mode in Python Script Node

Hi - I have hit a wall as to how I can move forward and would appreciate any assistance.

I have a filtered list of floor plan views (flat list in a node) and I want to make sure that the reveal hidden elements (the light bulb) is turned on in all of them, before continuing to process the views. There doesn’t even need to be a check if this mode is already on in some views, as this Dynamo graph will be run on a project immediately after opening.

I am running into difficulties due to my limited knowledge of both Python & the Revit API. I can’t figure another way to accomplish this task; I have searched forums, the webs, and existing node packages and was unable to find any similar solutions I can make simple edits to.

I am basically making blind attempts at editing a default Python Script Node and nothing seems to be working. At the very least, I’m sure this is a basic Python syntax issue, although I won’t rule out that I am not loading appropriate libraries either.

I am having a difficult time figuring out how I would even go about ‘calling’ the view method

‘EnableRevealHiddenMode’ from the Autodesk.Revit.DB.View class.
http://www.revitapidocs.com/2017.1/1e3fa28b-7738-ee26-f983-c9ebfb08f098.htm?section=seeAlsoToggle

Any help would be appreciated. I hope this is very simple.

Thanks in advance.

This might help you out.

https://forum.dynamobim.com/t/switch-to-show-hidden-elements/18110

Thanks for the response. I took a look at this forum posting earlier, which helped me to figure out what it is in the API that I needed to reference.

Unfortunately, there is little explanation as to how to use the API commands within the Python Node.

Again, I’m sure I am missing something very basic here.

Thanks!!

This will do it for you. It’s part of a package I am putting together but for now, you can copy and past it into a python node.

import clr

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference("RevitServices")

from RevitServices.Persistence import *
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

TransactionManager.Instance.EnsureInTransaction(doc)
doc.ActiveView.EnableRevealHiddenMode()
vId = UnwrapElement(doc.ActiveView.ToDSType(True))
TransactionManager.Instance.TransactionTaskDone()
OUT = vId

Wow - thanks Steven. This definitely does the trick, but only affects the first view (in the [0] position) in the list. Again, pardon my lack of Python programming, but what kind of changes would need to be made in order to run this node on all items in the list? I’d imagine a simple loop would do the trick.

I am so appreciative for your help.

Yes to make that change you will need a for loop to run the EnableRevealHiddenMode method.

doc.ActiveView.EnableRevealHiddenMode()
The doc.ActiveView line is collecting the active view in Revit and EnableRevealHiddenMode() is activating reveal hidden.

I am not super good with python but I think you will need to make the following change. I do not have time to test right now.

for i in IN[0]:
	i.EnableRevealHiddenMode()

you can set the out to be the list of views if you want to use them downstream.

OUT = IN[0]

Sorry if this does not work. I will try it out later.

I can’t seem to get it to loop properly. This outputs the correct list, but only 1 view gets the hidden elements view turned on.

for doc in IN[0]:
doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)
doc.ActiveView.EnableRevealHiddenMode()
vId = UnwrapElement(doc.ActiveView.ToDSType(True))
TransactionManager.Instance.TransactionTaskDone()

OUT = IN[0]

When I replace the line doc.ActiveView.EnableRevealHiddenMode() with i.EnableRevealHiddenMode() the node fails.

Sorry for any confusion. I meant for you to replace doc.ActiveView. Let me know if this works.

import clr

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference("RevitServices")

from RevitServices.Persistence import *
from RevitServices.Transactions import TransactionManager

TransactionManager.Instance.EnsureInTransaction(doc)
for i in IN[0]:
	i.EnableRevealHiddenMode()
   
TransactionManager.Instance.TransactionTaskDone()
OUT = IN[0]

Thank you for answering so quickly. Unfortunately, now this does not flip any of the views & also does not output any views from the node. The node outputs null & is the yellow warning color.

I’m thinking that it is possible that either the doc parameter needs to be redefined within the loop or that the views need to be unwrapped within the loop before being interacted with.

But again, I’m taking shots in the dark here.

Seriously, thank you for all your assistance.

What does the warning say? can you show a screen capture of what you are doing?

You were right. I was able to test this and its working. I will add this node to my new package smhNodes when I release it. Coming soon.

import clr

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference("RevitServices")

from RevitServices.Persistence import *
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

TransactionManager.Instance.EnsureInTransaction(doc)
for i in UnwrapElement(IN[0]):
	i.EnableRevealHiddenMode()
   
TransactionManager.Instance.TransactionTaskDone()
OUT = IN[0]

Steven, Amazing! Thank you for all your help.

Can you please mark the post that solved your problem. It helps others with the same question.

@Hal Just curious what are you doing after you turn it on.

@Steven I’m working on a method to remove all view-specific elements that are: hidden in view or outside the crop region (aka view-specific elements that are no longer visible in the view they are in). There are alot of bad habits of duplicating views in my office and this has a cumulative effect of massive slowdowns, after the new view is cropped and ‘re-used’. The view-specific elements I am processing out are : generic anno, detail groups, detail lines, CAD imports, text, masking regions, detail families

3 Likes

Ah very good. I am going to put that one in my back pocket.

Thanks Hal,

Steven