Find Bounding Boxes of Multiple Scope Boxes

Hi all,

I am trying to get the bounding box of a scope box. (Ultimately I am trying to extract a planar set of perimeter curves of one of the top or bottom faces.

I have tried the native nodes, but they seem to only like one item input at a time (input couldn’t take array - or complaints to that effect)

Could anyone help me out with this (preferably without producing a solid - due to increased processing requirements, although if this is a neccessity, its fine)

I had tried to modify one of the scripts I found from the wonderfully helpful @Andreas_Dieckmann. And his github page (I’ve been waiting to find a page like that for ages!!)

Anyway I had a stab at this, but I’ve got empty lists at the end …

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

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

scopeboxes = IN[0]

minlist = []
maxlist = []
elementlist = []

for item in scopeboxes:
	try:
		elementlist.append(item.BoundingBox[item])
		maxlist.append(item.BoundingBox[item].Max.ToPoint())
		minlist.append(item.BoundingBox[iyem].Min.ToPoint())
	except:
		donothing = 1
OUT = (elementlist,maxlist,minlist)

Any help would be much appreciated

Try this:

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

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

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

doc =  DocumentManager.Instance.CurrentDBDocument

scopeboxes = UnwrapElement(IN[0])

minlist = []
maxlist = []
elementlist = []

for item in scopeboxes:
	try:
		bBox = item.get_BoundingBox(doc.ActiveView)
		maxPoint = bBox.Max.ToPoint()
		minPoint = bBox.Min.ToPoint()
		
		elementlist.append(bBox)
		maxlist.append(maxPoint)
		minlist.append(minPoint)
		
	except:
		donothing = 1
		
OUT = [elementlist,maxlist,minlist]

I think the best way is extracting the geometry.

I have made some headway with the native nodes (I did have to go down the solid route - but didnt do any intersections)

As shown below.

Still trying to tackle how to use either the curves or a max and min point to define crop region

Ther are many related topics in the forum:

https://forum.dynamobim.com/search?q=Crop%20Region

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!