Elements inside scope box

#1

Hi,
Is there any way to select all elements of an scope box?
I need it to select those elements and set a parameter by zone

0 Likes

#2

There is.

Im not the author of the Python script… i ll link as soon as i found the original post.

import clr
clr.AddReference('RevitAPI')
clr.AddReference('System')
clr.AddReference('RevitNodes')
clr.AddReference('RevitServices')
import Revit
import RevitServices
from Autodesk.Revit.DB import *
from System.Collections.Generic import List
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
doc = DocumentManager.Instance.CurrentDBDocument

#Functions for list handling
def ProcessList(_func, _list):
   return map( lambda x: ProcessList(_func, x) if type(x)==list else _func(x), _list )

#Preparing input from dynamo to revit

def ToRevit(item):
	return item.ToRevitType(True)

if isinstance(IN[0], list):
	bblist = ProcessList(ToRevit, IN[0])
else:
	bblist = [ToRevit(IN[0])]

def collectElementsInBB(bb):
	outline = Outline(bb.Min, bb.Max)
	filter = BoundingBoxIntersectsFilter(outline)
	collector = FilteredElementCollector(doc, doc.ActiveView.Id).WherePasses(filter)
	return [e.ToDSType(True) for e in collector]

OUT = ProcessList(collectElementsInBB, bblist)
0 Likes

#3

I wanted to point out that using that method results in an “axis aligned bounding box”. Which is what Revit always gives you. This is worth consideration if your scope box or whatever element is not orthogonal.

So an angled element results in the following bounding box:

Which then yields the following result:

Just thought I would share because I have struggled through that many times. As for how to make this work as expected on scope boxes; that I am not sure of. :disappointed:

2 Likes

#4

Good to point out! I didnt even know.

0 Likes

#5

Hey John,

I like to use the Polygon Containment method :smiley:

How to see what elements are in which scope box

Whatever Konrad says!

Maybe you could use the bounding box to define the 3D extents?

Thanks for your awesome work!

Mark

0 Likes

#6

Woah! Classic john’s answer from 2016 coming back at me! lol :joy:

1 Like

#7

So if i understand:

Polygon for outline and Height from scopebox?

0 Likes

#8

I’m not at a PC right now, so I can’t be certain it works, but it sounds worth a quick try…

0 Likes

#9

That should get you going! I would say to poke at it and report back with your progress.

0 Likes

#10

Bedtime right now… Will get back with a graph tomorrow

0 Likes

#11

Use the bb min to create a plane, pull the curves to that, extrude curve as solid by the bb max and see what’s inside it…

I had a go here but with areas… Get elements inside an area

The complexity was things like walls which are partly inside (and have a line for a location) so it depends if you want those or not.

Hope that helps,

Mark

0 Likes

#12

@john_pierson @Mark.Ackerley Cant really find a way how to get this to work…
The green outline is my scopebox and the blue outline is the solid i manage to create with Dynamo.

Here is my graph so far, any help would be greatly appriciated :smiley:

0 Likes

#13

Try this…

Just to get you going I’ve set it to run in an active (3D) view…

InsideScopeBox.dyn (30.5 KB)

0 Likes

Geometry within a boundary & Geometry outside another geometry
#14

Thanks, @ Schasfoortyoerithat´s the solution!

0 Likes

#15

Im glad it worked for you. But like @john_pierson said in post 3: be carefull with not orthogonal elements / scopeboxes.
see the picture i posted in post 12. this will explain the difference between the area of elements that will be selected and the actual scopebox. (scopebox = green line, area of selected elements = blue line.)

Basicly my solution only works for non rotated scopeboxes :slight_smile:

0 Likes

#16

Don´t worry I have only ortogonal scope boxes.

0 Likes