I am looking for info on how to list CAD imports in families, is it even possible? I can list import instances directly in Revit but can’t figure out how to identify CAD imports in families. Any information you could provide would greatly help.
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
#Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
#Import ToDSType(bool) extensions method
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
#Reference the active Document and application
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
#Start scripting here:
bool = IN[0]
if bool == True:
col = FilteredElementCollector(doc).OfClass(ImportInstance).ToElements()
impinst = []
impname = []
for i in col:
if i.IsLinked != True:
impinst.append(i)
for j in impinst:
impname.append(j.Category.Name)
OUT = impinst, impname
else:
OUT = "Set bool to True"
@T_Pover@Jason_Trahan interesting problem. I’m about to release a new node which does precisely this. The only problem is its designed to work with the open document:
However, I’ve just amended it to take an optional path input so that any external file - be it a Family or other Revit document - can be audited silently (i.e. without needing to open the input files):
Marcello - From the .rvt project I would like to get a list of import instances from loaded/ placed families. From time to time users will insert .dwg or .sat into families (mostly generic models) and then load the family into the .rvt file. I want to find those families and the imports within.
Edit: I now see the link that @T_Pover provided from your blog, (thanks) I will give this a try!
Edit 2: @Martin_Spence1 - Thanks! Works great for finding imports, just looking to go deeper into families. @Thomas_Mahon looks promising, the open document will work, being silent is even better.
Thanks again - Wondering if I can find the families with CAD by finding the current views Imported Categories and check/ uncheck “Imports in Families” visibility. I’ll report back after snooping around.
@Jason_Trahan - Did you get anywhere with this? I’m looking at the CAD.ReportInstances node, and i don’t see how i can feed the list of loaded families into that node… at least not without first saving out a family library first…
Because its not possible to extract text from CAD files using the Revit API. Instead, the CAD files are exported to DXF so the TEXT and MTEXT entities can be parsed, then converted back into CADTextData which Revit can consume.
DXF only supports what the error message on the node states - its a limitation in the DXF format and there is nothing I can do about it (it screws up the layerNames internal indexing if I didn’t enforce the same limitations with the node).