But the preview image is coming null while opened as background document.

But the preview image is coming null while opened as background document.

sahin.ikbal
Advocate Advocate
426 Views
3 Replies
Message 1 of 4

But the preview image is coming null while opened as background document.

sahin.ikbal
Advocate
Advocate

I need the symbol images.
This way I'm loading the family files and taking preview image.
I'm trying to avoid loading into the file.
But the preview image "piTest" is coming null.

 

 

  using (var tempDoc = app.Application.OpenDocumentFile(rfa))
{
var symbols = new FilteredElementCollector(tempDoc).OfClass(typeof(FamilySymbol)).Cast<FamilySymbol>().ToList();
var symWithLocFromTems = symbols.Select(x => new SymWithLocation() { location = rfa, symbol = x });
var piTest = symbols[0].GetPreviewImage(new System.Drawing.Size(50, 50));
var tempFamData = CommonMethods.StaticDataGeneration(symWithLocFromTems);
FamData.AddRange(tempFamData);
}

 

 

0 Likes
427 Views
3 Replies
Replies (3)
Message 2 of 4

RPTHOMAS108
Mentor
Mentor

Not all types have an image i.e. it takes the image from the properties change type pull down in the UI.

 

If it exists there it should exist but a lot of things don't e.g. annotation symbols. I recall them having an image in older versions of Revit but perhaps I was imagining that.

0 Likes
Message 3 of 4

sahin.ikbal
Advocate
Advocate

After Loading the Family in current document the same is coming.
But background document loading it's coming null.
I guess There exists no UI for the background loaded family but as the preview is from UI so it does not exists.

I'm doing family loading and taking the preview for now.

0 Likes
Message 4 of 4

RPTHOMAS108
Mentor
Mentor

Do those families have images when you look in the UI?

 

I think the preview is stored in the family but not all categories store such an image. Not sure it should matter if you've only opened in the background. i.e. UI pull down is probably loading them JIT and storing for reuse. API is just extracting the image at point of use.

0 Likes