I am trying to check for CADLinkTypes and have them seperated into two lists, one for the links and one for the imports. According to the Revit API environment(when you hover over the CADLinkType) this can be done with the IsLink function, but I cannot figure out how to actually deploy this function. When I try to call it like another function I am told that it is not defined. This is what I have so far:
public void findLinks()
{
Document doc = this.ActiveUIDocument.Document;
string info = "";
foreach (Element e in new FilteredElementCollector(doc)
.OfClass(typeof(CADLinkType)))
{
CADLinkType fi = e as CADLinkType;
info += fi.Name + Environment.NewLine;
}
TaskDialog.Show("elements",info);
}
Any help on this would be greatly appreciated.
Solved! Go to Solution.
Solved by tjhogan2. Go to Solution.
An update for anyone else who might be curious on this matter, it seems like th isLink function may be obsolete/no longer available in the Revit api(not sure why it is still suggested when you hover over the text though). Instead I used IsExternalFileReference:
public void findLinkedCAD()
{
Document doc = this.ActiveUIDocument.Document;
string info = "";
foreach (Element e in new FilteredElementCollector(doc)
.OfClass(typeof(CADLinkType)))
{
if (e.IsExternalFileReference())
info += e.Name + " - " + e.Id + Environment.NewLine;
}
TaskDialog.Show("elements",info);
}
public void findImportedCAD()
{
Document doc = this.ActiveUIDocument.Document;
string info = "";
foreach (Element e in new FilteredElementCollector(doc)
.OfClass(typeof(CADLinkType)))
{
if (e.IsExternalFileReference())
{
}
else
{
info += e.Name + " - " + e.Id + Environment.NewLine;
}
}
TaskDialog.Show("elements",info);
}
I wound up doing the two as seperate macros because that just seemed to fit my needs better, but it shouldn't be to difficult to combine them into one that spits out both. Hope this helps anyone else having issues with this.