Change a lists Family Element Visibility Setting

Hello @stephen.donahay,

I realize its been over a year since you posted this but I came across your question while dealing with a similar issue. I also couldn’t find a solution here so I got someone at my firm who’s more proficient in python than me to help make a node for this. I thought I’de share the code here to help anyone else struggling with the same issue.

The code below was started from the code developed in this thread: https://forum.dynamobim.com/t/family-element-visibility-settings-python/35778

It will update the visibility/graphic settings of any elements in a family that contain the Visibility/Graphics Override parameter including view specific elements and nested families. I have not tested it with groups.

import clr
clr.AddReference('ProtoGeometry')
clr.AddReference('RevitServices')
clr.AddReference('RevitAPI')
import sys

from Autodesk.DesignScript.Geometry import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from Autodesk.Revit.DB import * 

doc = DocumentManager.Instance.CurrentDBDocument
# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

# Place your code below this line

def tolist(obj):
	if isinstance(obj, list):
		return obj
	else:
		return [obj]

#ModelCurve = UnwrapElement(IN[0])

out = []

for m in IN[0]:
	TransactionManager.Instance.EnsureInTransaction(doc)
	try:
		curr_element = UnwrapElement(m)
		fev = FamilyElementVisibility(FamilyElementVisibilityType.Model)
		fev.IsShownInCoarse = False
		curr_element.SetVisibility(fev)
		out.append("ModelCurve")
	except:
		# At this point we have a nested Family Instance
		curr_element = UnwrapElement(m)
		param = curr_element.LookupParameter("Visibility/Graphics Overrides")
		# This is the integer value for setting the Graphics to "Coarse"
		# Was found by using Revit Lookup Add-in
		param.Set(49214)
		out.append("Family Instance")
		continue
	TransactionManager.Instance.TransactionTaskDone()
	
OUT = out

The code is set up to hide elements at coarse detail level. for family geometry and detail lines its pretty easy to modify the code to change what visibility settings are on or off. for nested families, you can use the Revit Lookup add-in to find the integers you need to change the visibility. This blog post from The Building Coder explains more:

Cheers,