Hi friends,
I am attempting to use Dynamo to take a Revit family and export an image of the family geometry for every family type within the family. In my example below, I have taken the ootb desk family and am trying to create thumbnails of the desk:
import clr
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *clr.AddReference(‘System’)
from System.Collections.Generic import Listclr.AddReference(“System.Drawing”)
from System.Drawing import Sizeclr.AddReference(‘RevitNodes’)
import Revit
clr.ImportExtensions(Revit.Elements)clr.AddReference(‘RevitServices’)
import RevitServices
from RevitServices.Persistence import DocumentManagerdoc = DocumentManager.Instance.CurrentDBDocument
#Preparing input from dynamo to revit
elements = UnwrapElement(IN[0])images =
size = Size(100,100)
for e in elements:
images.Add(e.GetPreviewImage(size))OUT = images
The method leverages the ElementType.GetPreviewImage (credit to @SeanP for this solution) but the preview doesn’t update to reflect the physical change in geometry per family type.
This led me to directly opening the family document and view the current family type:
import clr
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManagerdoc = DocumentManager.Instance.CurrentDBDocument
if doc.IsFamilyDocument:
OUT = doc.FamilyManager.CurrentType
else: OUT = None
My thought is that I might be able to use the CurrentType property and change the current type using this:
Going this route, I think I need to add a Loop function but I am stumped on how to set a new current type, export the view, then cycle to the next type to set as current and export…
I’ll circle back tomorrow with an update on progress, but if there is any other forum posts or nodes that you might be aware of that can help address this challenge I would warmly accept your assistance. Thanks!
-Anthony