Close inactive views

Can anyone help me with a node/python to close inactive views?

found a node by Rhythm

I’ll leave this here for everyone:
image

I don’t see this node in the Rhythm package anymore. Can someone tell me if something similar exists somewhere else to close “inactive” windows?

It depends on what version of Revit you are using. For 2018 (and I am guessing earlier), the postable command was CloseHiddenWindows but in 2019+, that command was removed and CloseInactiveViews was added.

My guess was that the package was updated for 2019 and that node removed for compatibility reasons.

If you are using 2018, you can use this Python command:

# Enable Python support and load DesignScript library
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import RevitCommandId, UIApplication, ExternalCommandData, PostableCommand
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
# The inputs to this node will be stored as a list in the IN variables.
RunIt = IN[0]

# Place your code below this line
try:
	if RunIt == True:
		cmd = RevitCommandId.LookupPostableCommandId(PostableCommand.CloseHiddenWindows)#Revit 2018
		#cmd = RevitCommandId.LookupPostableCommandId(PostableCommand.CloseInactiveViews)#Revit 2019
		cmdId = cmd.Id
		uiapp.PostCommand(cmd)
		OUT = "Success"
	else:
		OUT = "RunIt is false"
except Exception as e:
	OUT = ["Failed",e]
3 Likes

Thanks @kennyb6, will it work for Revit 2019+ also?

If you remove the # sign in front of the 2nd cmd = line and put a # in front of the first cmd line, it should work with 2019