Export Families in Isometric View as an image to Excel

Dear All,

I am Trying to Get the Image of a family & I want to export that image to Excel.
Is that Possible.

I’ve Almost Reached my Output.

The Only Thing is to place the Image of the Family Beside the Excel.

Regards

1 Like

Could you share a sample revit file, a sample excel file and your Dynamo work (if you have started).
It would make this problem a lot easier to solve.

You can try the ElementType.GetPreviewImage method to retrieve the preview image of the Family Type you see inside Revit.

1 Like

Dear Daan,

Here is the Script & Excel Output.

Regards,EquipmenttoExcel.xlsx (26.7 KB) EquipmenttoExcel.dyn (71.3 KB)

Dear SeanP,

Thanks for the Reply, I don’t have this Node, May I Know From Which Package.?

Regards,

I don’t know if there is a node for it, but this Python will get you want you want I believe.

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference("System.Drawing")
from System.Drawing import Size

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

#Preparing input from dynamo to revit
element = UnwrapElement(IN[0])

size = Size(100,100)

image = element.GetPreviewImage(size)

OUT = image

9 Likes

Broooooooooooo,

You are Awesome… :star_struck: Thank you So Muchhhh…
Can I Export this to Excel?
I’ve Tried to Export it to Excel but didn’t happen. Tried other ways also.
But unable to get that image out.

Here i need to place the picture.
image

I’ve Tried this. I would like to get all the Element images into a Excel.


Regards

I believe you need the families of the elements, not the types… the Element.ElementType gives you the type, not the family

1 Like

I think the problem is that the python doesn’t current handle a list of types.

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference("System.Drawing")
from System.Drawing import Size

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

doc = 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

4 Likes

The Family Type that is being provided in the correct element for this. The node wasn’t handling a List of items, but the format was correct.

1 Like

Okay, Thank you @SeanP

How can we improve the image quality using the python code? I tested it and it doesn’t matter if you put size (100,100) than size (2000,2000) for example.

Is there a way to choose what perspective of the isometric cube to use to generate the images of families? Sometimes the images are showing the back of the element or facing up, in other axis, if element is face based.

I believe the preview image is based on the last view updated for the Thumbnail in the actual family. To get a different preview, you would need to update the Thumbnail for the family.

I saw achilab node that exports a view of a project as an image but I would like to do it with a 3D view of a Revit family.

It’s annoying to place every single family in a project, isolate them and align the view to same angle of isometric view to see if I can get an image of the family.

Hey Sean, first of all, thanks for the script, it works like a charm. The result is a proper image (in Dynamo).
However, I am having problems exporting/ inserting it into an Excel table. When using the Data.ExportExcel node, the data written in the excel table is a text : “System.Drawing.Bitmap”, instead of the actual image. Any idea on how to fix this ?

Many thanks !

@pmit
Hello
try with Clipboard and Paste
an example here

1 Like