Find Bounding Boxes of Multiple Scope Boxes

Hi everyone,

Cheers for all the help once again.

By following the link posted above, the very first post was ‘set room boundary by curve’ - completely ideal. It even works aswell, however only when dealing with one view and one curve. Crop Region by curve

I’ve been learning a bit of Python and I feel on the cusp of getting this sort of stuff down.

However I think I can diagnose the issue, I just can’t solve it. My diagnosis is that there needs to be another for loop on the go. (or one grand mega for loop encompassing all things)

When feeding multiple views and inputs, i’m getting an error, expected a curve, got a list. (Its waiting for a single item and has received multiple. Also the final few lines applying the crop are not within a loop and as such will only execute once.

Code as found below

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

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

doc = DocumentManager.Instance.CurrentDBDocument

#prepare input
view = UnwrapElement(IN[0])
curves = IN[1]

#Create curveloop
loop = CurveLoop()
for c in curves:
	loop.Append(c.ToRevitType())

#Set cropregion in Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
view.CropBoxActive = True
view.GetCropRegionShapeManager().SetCropShape(loop)
TransactionManager.Instance.TransactionTaskDone()
OUT = view

I’ve attempted to make a list ‘curvelist’ and iterate through the curves to append each one individually. Then iterate again through that to get each loop.

I’ve thrown a for loop around teh bottom bit, but i get the feeling its should be one loop encompassing both curves and views at once, not dealing with the curves, then dealing with the views.

import clr

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

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

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

doc = DocumentManager.Instance.CurrentDBDocument

#prepare input
views = UnwrapElement(IN[0])
curves = IN[1]
curvelist =[]
viewlist = []

#Create curveloop
loop = CurveLoop()
for i in curves:
	curvelist.append(i)
	for c in curvelist:
		loop.Append(c)

#Set cropregion in Transaction
for view in views:
	TransactionManager.Instance.EnsureInTransaction(doc)
	view.CropBoxActive = True
	view.GetCropRegionShapeManager().SetCropRegionShape(loop)
	TransactionManager.Instance.TransactionTaskDone()
	viewlist.append(view)

OUT = view

I’m so excited for the day i finally crack this shit!