# Apply Parameter if element lies within Bounding Box

**URL:** <https://forum.dynamobim.com/t/apply-parameter-if-element-lies-within-bounding-box/2279>\
**Category:** Packages\
**Created:** [September 30, 2015, 3:15am UTC](https://forum.dynamobim.com/t/apply-parameter-if-element-lies-within-bounding-box/2279 "2015-09-30T03:15:30Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas\_Bilbe](https://avatars.discourse-cdn.com/v4/letter/t/5f9b8f/32.png) [@Thomas\_Bilbe](https://forum.dynamobim.com/u/Thomas_Bilbe)\
**Post date:** [September 30, 2015, 3:15am UTC](https://forum.dynamobim.com/t/apply-parameter-if-element-lies-within-bounding-box/2279/1 "2015-09-30T03:15:30Z")

</div>

Hi,

&nbsp;

As the title says I am trying to apply a drawing number to an element if the element lies within a specific Space/ Room/ Zone.

I understand how to set and get the required parameters, but it is a case of the boolean I believe that I am stuck on.

I am thinking that if I could take the bounding box coordinates and prove if the element geometry is modelled inside the region - if true apply the specific parameter value - if false test next region.

Thanks in advance,

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [September 30, 2015, 3:38am UTC](https://forum.dynamobim.com/t/apply-parameter-if-element-lies-within-bounding-box/2279/2 "2015-09-30T03:38:26Z")

</div>

To check if an element (represented by a point, actually) is within a bounding box you could use **_BoundingBox.Contains_**

---

<div class="post-metadata">

**Author:** ![Peter\_Kompolschek](https://avatars.discourse-cdn.com/v4/letter/p/dec6dc/32.png) [@Peter\_Kompolschek](https://forum.dynamobim.com/u/Peter_Kompolschek)\
**Post date:** [September 30, 2015, 3:40am UTC](https://forum.dynamobim.com/t/apply-parameter-if-element-lies-within-bounding-box/2279/3 "2015-09-30T03:40:09Z")

</div>

Maybe you search the forum for “grouping casework by room location”

That should help

---

<div class="post-metadata">

**Author:** ![Thomas\_Bilbe](https://avatars.discourse-cdn.com/v4/letter/t/5f9b8f/32.png) [@Thomas\_Bilbe](https://forum.dynamobim.com/u/Thomas_Bilbe)\
**Post date:** [September 30, 2015, 4:34am UTC](https://forum.dynamobim.com/t/apply-parameter-if-element-lies-within-bounding-box/2279/4 "2015-09-30T04:34:21Z")

</div>

Rather than the bounding box contains I used BoundingBox.Intersects (Cross Product lacing) from the resulting boolean, I am stuck on how to proceed!

Should I use the result into Logic.If ?

I am stumbling because I think there maybe another step involved? **- the parameter needs to include the correct room number! how does dynamo track this?!**

Peter - I had a look through the forum post and most of it went over my head! still very much a beginner here!!!

thanks again,

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [September 30, 2015, 7:19am UTC](https://forum.dynamobim.com/t/apply-parameter-if-element-lies-within-bounding-box/2279/5 "2015-09-30T07:19:34Z")

</div>

The attached file should hopefully serve as a guide for you.

File: [RoomContains.dyn](http://dynamobim.com/wp-content/uploads/forum-assets/testingwaters/09/30/RoomContains.dyn)

File: [Demo.rvt](http://dynamobim.com/wp-content/uploads/forum-assets/testingwaters/09/30/Demo.rvt)

![20150930-3](http://dynamobim.com/wp-content/uploads/forum-assets/testingwaters/09/30/20150930-3-600x227.jpg)

---

<div class="post-metadata">

**Author:** ![john\_pierson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/john_pierson/32/191977_2.png) [@john\_pierson](https://forum.dynamobim.com/u/john_pierson)\
**Post date:** [September 30, 2015, 8:00am UTC](https://forum.dynamobim.com/t/apply-parameter-if-element-lies-within-bounding-box/2279/6 "2015-09-30T08:00:18Z")

</div>

What are you trying to locate in rooms? There’s a node in Rhythm called Element.Room which works great for furnishing and casework and a few others…

![2015-09-30_07h28_53](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/2X/e/eeb7f0fbdd4f3fb337c2c3d78fb9c1e37e045ced.png)

---

<div class="post-metadata">

**Author:** ![Thomas\_Bilbe](https://avatars.discourse-cdn.com/v4/letter/t/5f9b8f/32.png) [@Thomas\_Bilbe](https://forum.dynamobim.com/u/Thomas_Bilbe)\
**Post date:** [September 30, 2015, 8:51am UTC](https://forum.dynamobim.com/t/apply-parameter-if-element-lies-within-bounding-box/2279/7 "2015-09-30T08:51:49Z")

</div>

Trying to locate the Ductwork!

Ultimate goal is to append a new parameter that can be used in our fabrication processes. It would also translate to our Planning dept. as most of our contracts allow for access to site on a zone by zone basis.

I have gotten to the point with the help of Vikram but feel there is still a step in ensuring the Duct is given the correct Zone/ Space identifier.

A sort of if statement - If Duct lies in Room/Space 1 then name duct accordingly.

The BoundingBox.Contains laced Cross, tests all spaces with all instances of duct and correctly identifies if the duct lies in the region, but I need another step to append the correctly named space to the duct.!

Cheers

&nbsp;

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [September 30, 2015, 10:05am UTC](https://forum.dynamobim.com/t/apply-parameter-if-element-lies-within-bounding-box/2279/8 "2015-09-30T10:05:11Z")

</div>

Thomas, going by what you’ve described above using a Bounding box may not be accurate as the extents of the bounding box are determined taking the WCS as reference. If your rooms/spaces/zones are at angles it can be quite misleading.

_BoundingBox.ByGeometryCoordinateSystem_ may be better, but even that may not be suitable for irregular spaces.

Why don’t you consider avoiding the bounding box and use _Geometry.DoesIntersect_ instead.

The example I’ve provided in my earlier reply should help guide you to associate a duct with a room.

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [September 30, 2015, 12:21pm UTC](https://forum.dynamobim.com/t/apply-parameter-if-element-lies-within-bounding-box/2279/9 "2015-09-30T12:21:04Z")

</div>

Hi Thomas,

You can also try custom node called Tool.GetSurroundingElements from Steam Nodes. It will give you the location of ducts in which room/space it is located. I have created a sample below in which i have two Duct names called SAD (Supply Air Duct) and RAD (Return Air Duct). Good Luck!

![Duct System1](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/2X/4/49f3e2d1e1fecae18a47da078977a2ffd6d59bfc.png)

![Duct System](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/2X/f/f3eef60137d0280d0aec0884ccff03a4cafd47dd.png)

---

<div class="post-metadata">

**Author:** ![Thomas\_Bilbe](https://avatars.discourse-cdn.com/v4/letter/t/5f9b8f/32.png) [@Thomas\_Bilbe](https://forum.dynamobim.com/u/Thomas_Bilbe)\
**Post date:** [October 1, 2015, 3:08am UTC](https://forum.dynamobim.com/t/apply-parameter-if-element-lies-within-bounding-box/2279/10 "2015-10-01T03:08:37Z")

</div>

Vikram, I had tried using the .DoesIntersect previously. But I always got stuck on the referencing the correct space to the correct duct! I guess its all a learning process! and lots of head bashing against a wall until the penny drops!

&nbsp;

Kulkul, Thanks massively for the node advice, I have used it and it works! one quick question on the tolerance input - What is the integer referencing? is it proximity to the boundary?!

I will try and clean up the definition when I get some time today and post it if anyone is interested?

Thanks again guys.

T

---

<div class="post-metadata">

**Author:** ![Alan\_Farrell1](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@Alan\_Farrell1](https://forum.dynamobim.com/u/Alan_Farrell1)\
**Post date:** [May 3, 2016, 4:40am UTC](https://forum.dynamobim.com/t/apply-parameter-if-element-lies-within-bounding-box/2279/11 "2016-05-03T04:40:24Z")

</div>

Hi Thomas

How did you get on this script?

I have been trying something similar myself but with no joy

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [May 3, 2016, 6:13am UTC](https://forum.dynamobim.com/t/apply-parameter-if-element-lies-within-bounding-box/2279/12 "2016-05-03T06:13:12Z")

</div>

Hi Alan,

What are you trying to create something similar. Could you be more specific or create a new topic with screenshot of your workflow instead of hijacking this one.

Thanks,

---

<div class="post-metadata">

**Author:** ![Salma\_BOUAICH](https://avatars.discourse-cdn.com/v4/letter/s/b5e925/32.png) [@Salma\_BOUAICH](https://forum.dynamobim.com/u/Salma_BOUAICH)\
**Post date:** [August 1, 2016, 10:22am UTC](https://forum.dynamobim.com/t/apply-parameter-if-element-lies-within-bounding-box/2279/13 "2016-08-01T10:22:56Z")

</div>

Hi,

I’m trying to do the same thing. Locate ducts and pipes in my project.  
i noticed that it’s easier to locate ducts and pipes in levels then in zones, spaces … (2D).

in order to do so, i tried to use element.location node to be able to get pipe’s coordinate, but when i connect the results with the boudingBox.Contains i get an empty list.

is there an other way to locate ducts and pipe in spaces ?

![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/2X/3/3b163fa5d15d64ddeef85d7d8500555fcda6eac5.PNG)

Thanks in advance,

---

<div class="post-metadata">

**Author:** ![Andrea\_Botti](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@Andrea\_Botti](https://forum.dynamobim.com/u/Andrea_Botti)\
**Post date:** [March 24, 2017, 2:52pm UTC](https://forum.dynamobim.com/t/apply-parameter-if-element-lies-within-bounding-box/2279/15 "2017-03-24T14:52:33Z")

</div>

@john_pierson is a similar node available for MEP spaces?

---

<div class="post-metadata">

**Author:** ![john\_pierson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/john_pierson/32/191977_2.png) [@john\_pierson](https://forum.dynamobim.com/u/john_pierson)\
**Post date:** [March 24, 2017, 4:20pm UTC](https://forum.dynamobim.com/t/apply-parameter-if-element-lies-within-bounding-box/2279/16 "2017-03-24T16:20:10Z")

</div>

Element.Space is also in Rhythm

---

<div class="post-metadata">

**Author:** ![Andrea\_Botti](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@Andrea\_Botti](https://forum.dynamobim.com/u/Andrea_Botti)\
**Post date:** [March 27, 2017, 2:32pm UTC](https://forum.dynamobim.com/t/apply-parameter-if-element-lies-within-bounding-box/2279/17 "2017-03-27T14:32:07Z")

</div>

great! Sorry I could not spot it and assumed it was not there

---

<div class="post-metadata">

**Author:** ![Alberto\_Tono](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alberto_tono/32/15925_2.png) [@Alberto\_Tono](https://forum.dynamobim.com/u/Alberto_Tono)\
**Post date:** [April 20, 2017, 2:58pm UTC](https://forum.dynamobim.com/t/apply-parameter-if-element-lies-within-bounding-box/2279/19 "2017-04-20T14:58:08Z")

</div>

```
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitNodes')
clr.AddReference('RevitServices')
import Revit
import RevitServices
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
doc = DocumentManager.Instance.CurrentDBDocument

#Preparing input from dynamo to revit
bbs = IN[0]
output = []

for bb in bbs:
	bbx = bb.ToRevitType()
	outline = Outline(bbx.Min, bbx.Max)
	#filter = BoundingBoxIntersectsFilter(outline)
	filter = BoundingBoxIsInsideFilter(outline)
	collector = FilteredElementCollector(doc, doc.ActiveView.Id).WherePasses(filter)
	for i in collector:
		i.ToDSType(True)
		output.append(i)
	
OUT = output

```

@Thomas_Bilbe and @Andrea_Botti hope this could help. Let me know.

---

<div class="post-metadata">

**Author:** ![carmineaucello](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@carmineaucello](https://forum.dynamobim.com/u/carmineaucello)\
**Post date:** [December 20, 2022, 8:42am UTC](https://forum.dynamobim.com/t/apply-parameter-if-element-lies-within-bounding-box/2279/20 "2022-12-20T08:42:08Z")

</div>

> [@Kulkul](#):
>
> ou can also try custom node called Tool.GetSurroundingElements from Steam Nodes. It will give you the location of ducts in which room/space it is located. I have created a sample below in which i have two Duct names called SAD (Supply Air Duct) and RAD (Return Air Duct). Good Luck!

Hi Kulkul  
I am trying to do the same thing: to ask dynamo to pick up the “system families” elements, such as ducts/pipes/walls ecc, in order to get the room/space they lay in with the purpose of automatically copy/paste the room name to another paramter of my choice. Anyway, I can’t seem to be able to zoom in the 2 images you shared some years ago. Would it be possible for you to help?

Same thing with the Vikram files. It seems they expired.

Thanks guys

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [December 20, 2022, 6:43pm UTC](https://forum.dynamobim.com/t/apply-parameter-if-element-lies-within-bounding-box/2279/21 "2022-12-20T18:43:13Z")

</div>

Hi @carmineaucello

> [@carmineaucello](#):
>
> can’t seem to be able to zoom in the 2 images you shared some years ago. Would it be possible for you to help?

Those images are old. Might be able to help if you, if you could share rvt file.
