Hi All
I am trying to create a python script that dimensions the levels and grids of all views on sheets. I have managed to produce the python script below, which gets the crop regions of the views so I can use them as a reference for placing the dimensions. However, I am struggling to understand how to filter the levels/grids within the views using the filtered element collector. I could easily do this using the OOTB node All Elements of Category in View, but I am trying to do everything using Python.
Thanks for your assistance. @john_pierson
# CODE
# Get Viewports on Sheet
all_viewports = FilteredElementCollector(doc, doc.ActiveView.Id).OfCategory(BuiltInCategory.OST_Viewports).WhereElementIsNotElementType().ToElements()
all_viewports_flat = []
for view in all_viewports:
if isinstance (view,list):
for v in view:
all_viewports_flat.append(v)
else:
all_viewports_flat.append(view)
# Get Views
all_views = []
for viewport in all_viewports_flat:
viewId = viewport.ViewId
all_views.append(doc.GetElement(viewId))
# Get Crop Regions
all_cropRegions = []
for view in all_views:
viewShapeManager = view.GetCropRegionShapeManager()
all_cropRegions.append(viewShapeManager.GetCropShape())
# Flatten Crop Regions
cropLines = []
for line in all_cropRegions:
for l in line:
for ll in l:
cropLines.append(ll.ToProtoType())
# Chop Line List
listLength = len(cropLines)
chopMultiple = listLength / 4
splitLengths = [4]*chopMultiple
Input = iter(cropLines)
choppedLines = [list(islice(Input,elem)) for elem in splitLengths]
# Assign your output to the OUT variable.
OUT = choppedLines