Hi everyone,
I would like to batch edit some door families but I am facing an issue with setting nested family geometry visibility through Dynamo and Python.
I managed to find a Jeremy blog post from 2014 about how to handle geometry visibility and after testing with both Revit Lookup and Dynamo for the integer conresponding to my desired settings I came up with this code :
import clr
import sys
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
vues = FilteredElementCollector(doc).OfClass(ViewPlan)
RDC = [x for x in vues if x.Name == "Rez-de-chaussée"][0]
ETQ = [y for y in FilteredElementCollector(doc,RDC.Id).OfClass(FamilyInstance) if y.LookupParameter("Famille").AsValueString() == "A_SYM_ETQ_POR"][0]
ETQparam = ETQ.get_Parameter(BuiltInParameter.GEOM_VISIBILITY_PARAM)
TransactionManager.Instance.ForceCloseTransaction()
TransactionManager.Instance.EnsureInTransaction(doc)#
ETQparam.Set(49152)
TransactionManager.Instance.TransactionTaskDone()
TransactionManager.Instance.ForceCloseTransaction()
OUT = ETQparam.AsInteger(), ETQ.Id
To quickly break it down, itâs executed inside a family document for the moment :
- Gets the all FloorPlan views of the family
- Gets the FloorPlan view wich owns the Annotation family Iâd like to modify
- Gets the family instance to modify
- Gets its
GEOM_VISIBILITY_PARAM
- Modifies the parameter value
Th default Value of GEOM_VISIBILITY_PARAM
for annotations is 57344, the target value according to Revitlookup is 49152 (default minus fine uncheck).
After running the script, the annotation instance disappears from the family. The element stills exists but is not visible, and doesnât show when loaded into a project file. When snooping with elementId, itâs still there and GEOM_VISIBILITY_PARAM
returns 49154 as integer value, geometry parameter in revit UI is set as expected (fine unchecked)
I tried to set it to 49154 directly, but still it makes the annotation disappear.
I tried with another kind of nested family (door category) and the script worked as expected : geometry visibily set with fine unchecked and family representation still visible. (integers are different though as they include plan and section visibility)
Of course, I checked the visibily instance parameter. Itâs not that
BeforeScript :
AfterScript :
The locks are proving the object is still there