Create a family library document - advice

Hi I am trying to create to a document like the image below. It has a preview image of the family in the first column. The type name in the second column. And the file path of the family document in the third column.

I have managed to get all the pieces required to build the family library document. The difficult part is exporting this information to a suitable place. The image below uses a Bumblebee package workflow to embed the images in the Excel document but it is not stable and the images if made larger overlap so large or small not useful.

I was hoping GoogleSheets might work but BIMPlus Googlesheet package can’t embed images just image URLs and I can’t automate uploading lots of images. So I think that is also not a solution.

So I am thinking of creating a drafting view and importing images and creating text notes. But I would prefer an external document to avoid opening a Revit project. Does anyone know of a way of getting this information from Dynamo into a document for easy viewing?

Any suggestions welcome.

Document like this

Writing Preview Images to Excel.dyn (93.9 KB)

Script contents: Python get a list of furniture family types. Python get family folder location. Python get Preview image of Family. Export Images. Create Excel. Bumblebee Embed images.

Edit: Would it be possible to use IronPython Microsoft Word Interop to Embed images in word. I have limited python skills also on my work computer I can not install extra Python modules.

I think the excel approach is good enough, no need to jump into word. Check this question in stackoverflow and resizing images in excel:

Or if you just want to give a try to word:

https://stackoverflow.com/questions/38227689/office-interop-word-how-to-add-a-picture-to-document-without-getting-compressed#:~:text=The%20common%20way%20to%20insert,Add()%3B%20Range%20docRange%20%3D%20wordDoc.

1 Like

You can already do larger images… why not make the excel lines larger so they don’t overlap?

When you adjust the row height it stretches and distorts the image. It doesn’t remove the overlapping either. But I could possibly do something about that with an Excel macro I could buy except the images keep disappearing. So I am going to investigate exporting to Word. I will post here if I get something useful.

Hello,
an example using Clipboard and Paste

# coding: utf-8 
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

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

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

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = uiapp.ActiveUIDocument


import System
from System import Environment
from System import Array
from System.Collections.Generic import *

clr.AddReference('System.Drawing')
import System.Drawing
from System.Drawing import *
clr.AddReference('System.Windows.Forms')
from System.Windows.Forms import Clipboard


clr.AddReferenceByName('Microsoft.Office.Interop.Excel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' )
from Microsoft.Office.Interop import Excel
from System.Runtime.InteropServices import Marshal


class ExcelUtils():
	def __init__(self, expSettings, filepath, sizebitmap):
		self.expSettings = expSettings
		self.filepath = filepath
		self.sizebitmap = sizebitmap
		print self.filepath
		
		
	def exportXls(self):
		
		ex = Excel.ApplicationClass()
		ex.Visible = True
		ex.DisplayAlerts = False
		workbook = ex.Workbooks.Add()
		workbook.SaveAs(self.filepath)
		ws = workbook.Worksheets[1]	
		nbr_row = len(self.expSettings)
		nbr_colum = len(self.expSettings[0])
		#
		xlrange  = ws.Range[ws.Cells(1, 2), ws.Cells(nbr_row, nbr_colum )]
		xlrange.EntireRow.RowHeight  = self.sizebitmap.Height
		ws.Range("a1").EntireColumn.ColumnWidth = self.sizebitmap.Width / 4
		a = Array.CreateInstance(object, nbr_row, nbr_colum - 1)
		#
		for indexR, row in enumerate(self.expSettings):
			for indexC , value in  enumerate(row):
				if indexC == 0 and value is not None:
					Clipboard.SetDataObject(value)
					rng  = ws.Range[ws.Cells(indexR + 1, 1), ws.Cells(indexR + 1 , 1)]
					ws.Paste(rng, False)
					
				else:
					a[indexR, indexC - 1] = value
				
		#copy Array in range			
		xlrange.Value2 = a		
		used_range = ws.UsedRange	
		for column in used_range.Columns:
			column.AutoFit()
			
toList = lambda x : x if hasattr(x, '__iter__') else [x]		
listcat = toList(UnwrapElement(IN[0]))			
#make filter			
lstbipCat = [System.Enum.ToObject(BuiltInCategory, x.Id.IntegerValue) for x in listcat]			
filtercat = ElementMulticategoryFilter(List[BuiltInCategory](lstbipCat))
#collector
fecSymb = FilteredElementCollector(doc).WherePasses(filtercat).WhereElementIsElementType().ToElements()
outdata = []
imgSize = Size( 100, 100 )
for symb in fecSymb:
	bitm = symb.GetPreviewImage(imgSize) 
	famName = symb.Family.Name
	symbName = Element.Name.GetValue(symb)
	outdata.append([bitm, famName, symbName])
	
#define folder to export		
directory = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)

objXls = ExcelUtils(outdata, directory + '\\test.xls', imgSize)
objXls.exportXls()

OUT = directory
2 Likes