I got something like this:
public void PreviewLinkedCAD(Document doc)
{
IList<ImportInstance> importIntaces = new FilteredElementCollector(doc)
.OfClass(typeof(ImportInstance))
.Cast<ImportInstance>()
.Where(i => i.IsLinked == true).ToList();
foreach (ImportInstance ints in importIntaces)
{
if (ints.Category.Name.EndsWith(".dwg"))
{
ElementId typeId = ints.GetTypeId();
CADLinkType cadLink = doc.GetElement(typeId) as CADLinkType;
frmMain frm = new frmMain();
frm.BackgroundImage = cadLink.GetPreviewImage(new System.Drawing.Size(128, 128));
frm.Show();
}
}
}
The GetPreviewImage method will not work for what I'm trying to do. Sorry about that.
Here is an explanation:
Import Instances don’t have preview images in the Revit user interface either.
If you go to place a family instance, the preview image is displayed like this:

For a Import Symbol, the preview image square in the type selector remains blank:
This is why GetPreviewImage has nothing it can return. There is a workaround to achieve what you want anyway:
You could create a temporary view, temporarily hide everything except the import instance, and create a snapshot of that.
¯\_(ツ)_/¯
Let it work like a charm.
Mustafa Salaheldin


Digital Integration Manager, DuPod
Facebook |
Twitter |
LinkedIn