Hi Jacob,
thank you for your response. i finally got it working with a cropbox boundingboxXYZ.
trial and error was the key to succes in my case! This is the result for other people to enjoy!
it tests views for titleblock size and creates a list with titleblock types parallel to the view list.
a great result for my first script!
`import System
from System.Collections.Generic import *
import clr
clr.AddReference(‘RevitServices’)
import RevitServices
from RevitServices.Persistence import DocumentManager
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
views_single = UnwrapElement(IN[0])
titleblock_family = UnwrapElement(IN[1])
t_height = UnwrapElement(IN[2])
t_width = UnwrapElement(IN[3])
titleblock_type_id = titleblock_family.GetFamilySymbolIds()
titleblock_types_tosort = [doc.GetElement(i) for i in titleblock_type_id]
titleblock_height_us = [float(i.LookupParameter(t_height).AsValueString()) for i in titleblock_types_tosort]
titleblock_width_us = [float(i.LookupParameter(t_width).AsValueString()) for i in titleblock_types_tosort]
sheet_surface = [i*j for i, j in zip(titleblock_width_us, titleblock_height_us)]
titleblock_types = [i for j, i in sorted(zip(sheet_surface, titleblock_types_tosort))]
titleblock_height = [float(i.LookupParameter(t_height).AsValueString()) for i in titleblock_types]
titleblock_width = [float(i.LookupParameter(t_width).AsValueString()) for i in titleblock_types]
cropbox_minmax_vs = [[i.CropBox.Min, i.CropBox.Max] for i in views_single]
cropbox_vs =
for i in cropbox_minmax_vs:
cropbox_vs.append(abs(i[0].X - i[1].X)*304.8)
cropbox_vs.append(abs(i[0].Y - i[1].Y)*304.8)
cropbox_vs = [cropbox_vs[i:i + 2] for i in xrange(0, len(cropbox_vs), 2)]
view_scale_vs = [i.Scale for i in views_single]
cropbox_dim_vs =
for i, j in zip(cropbox_vs, view_scale_vs):
for k in i:
cropbox_dim_vs.append(k/j)
cropbox_dim_vs = [cropbox_dim_vs[i:i + 2] for i in xrange(0, len(cropbox_dim_vs), 2)]
titleblock_list_vs =
for i in cropbox_dim_vs:
n = 0
if (i[0]) >= titleblock_width[-1] or (i[1]) >= titleblock_height[-1]:
titleblock_list_vs.append(titleblock_types[-1])
else:
while (i[0]*1.2) >= titleblock_width[n] or (i[1]*1.2) >= titleblock_height[n] and n < (len(titleblock_types)-1):
n += 1
else:
titleblock_list_vs.append(titleblock_types[n])
OUT = titleblock_list_vs`