# Help needed to make Get Spatial Element Boundary Location work with linked elements

**URL:** <https://forum.dynamobim.com/t/help-needed-to-make-get-spatial-element-boundary-location-work-with-linked-elements/37071>\
**Category:** Developers\
**Tags:** python, api\
**Created:** [June 12, 2019, 6:55pm UTC](https://forum.dynamobim.com/t/help-needed-to-make-get-spatial-element-boundary-location-work-with-linked-elements/37071 "2019-06-12T18:55:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sorin\_T](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@Sorin\_T](https://forum.dynamobim.com/u/Sorin_T)\
**Post date:** [June 12, 2019, 6:55pm UTC](https://forum.dynamobim.com/t/help-needed-to-make-get-spatial-element-boundary-location-work-with-linked-elements/37071/1 "2019-06-12T18:55:04Z")

</div>

Hello, I am trying to modify the Clockwork Room.Boundaries node to give me the elements from a linked file so that i can get parameter info from them.

The Room.Boundaries node uses GetSpatialElementBoundaryLocation() method and i`m not sure how to use that in such a way to get those bounding elements, from what i skimmed in the RevitApiDocs i can`t find a specific solution.

I am also not a complete expert with Python but i can work with it.

My question is: what would you recommend as a method or if you know a different node/package that can help me make these changes to the node and get the info i need.  
PS: the project is quite large at around 3000 rooms so getting the geometry and doing a “manual check” is a solution i would like to explore last.

Can anyone help?

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [June 12, 2019, 8:51pm UTC](https://forum.dynamobim.com/t/help-needed-to-make-get-spatial-element-boundary-location-work-with-linked-elements/37071/2 "2019-06-12T20:51:33Z")

</div>

Normally these types of custom nodes are set to run on the active document. You’ll have to make sure you specify a linked document and run the same methods with the linked doc.

---

<div class="post-metadata">

**Author:** ![Sorin\_T](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@Sorin\_T](https://forum.dynamobim.com/u/Sorin_T)\
**Post date:** [June 13, 2019, 9:40am UTC](https://forum.dynamobim.com/t/help-needed-to-make-get-spatial-element-boundary-location-work-with-linked-elements/37071/3 "2019-06-13T09:40:05Z")

</div>

I have tried that and i get nulls where the elements are, i believe i have to change how i get those elements maybe but i have no idea where to do that.

in the case of `elist.append(doc.GetElement(bface.SpatialBoundaryElement.HostElementId))`i already have get element on the linked doc so i don`t really understand why i would get nulls.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/5/7531e5950da998d2371098d2c349289caaf32fda.png)

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

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

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

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

items = UnwrapElement(IN[0])
doc = UnwrapElement(IN[1][0])
facetypes = []
facemats = []
faceelements = []
faceareas = []
faces = []

for item in items:
    calculator = SpatialElementGeometryCalculator(doc)
    options = Autodesk.Revit.DB.SpatialElementBoundaryOptions()
# get boundary location from area computation settings
    boundloc = Autodesk.Revit.DB.AreaVolumeSettings.GetAreaVolumeSettings(doc).GetSpatialElementBoundaryLocation(SpatialElementType.Room)
    options.SpatialElementBoundaryLocation = boundloc
    mlist = []
    tlist = []
    elist = []
    alist = []
    flist = []
    try:
    	results = calculator.CalculateSpatialElementGeometry(item)
	for face in results.GetGeometry().Faces:
		for bface in results.GetBoundaryFaceInfo(face):
			tlist.append(str(bface.SubfaceType))
			if bface.GetBoundingElementFace().MaterialElementId.IntegerValue == -1:
				mlist.append(None)
			else:
				mlist.append(doc.GetElement(bface.GetBoundingElementFace().MaterialElementId))
			elist.append(doc.GetElement(bface.SpatialBoundaryElement.HostElementId))
			
except:
	pass	

faceelements.append(elist)

OUT = faceelements
```

---

<div class="post-metadata">

**Author:** ![maciek.glowka](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/maciek.glowka/32/70695_2.png) [@maciek.glowka](https://forum.dynamobim.com/u/maciek.glowka)\
**Post date:** [June 13, 2019, 1:02pm UTC](https://forum.dynamobim.com/t/help-needed-to-make-get-spatial-element-boundary-location-work-with-linked-elements/37071/4 "2019-06-13T13:02:26Z")

</div>

Hi,  
try the code below. It’s not easy for me to analyse somebody else’s code so I am not sure what is the problem with the one above, but you are not setting the spatial element boundary options - it might be the problem.

```
import clr

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

#The inputs to this node will be stored as a list in the IN variables.
rooms = UnwrapElement(IN[0])
linkInstance = UnwrapElement(IN[1])
linkedDoc = linkInstance.GetLinkDocument()

options = SpatialElementBoundaryOptions()
options.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Finish

calculator = SpatialElementGeometryCalculator(linkedDoc,options)
output = []

for r in rooms:
	try:
		results = calculator.CalculateSpatialElementGeometry(r)
		solid = results.GetGeometry()
		elements = []
		for f in solid.Faces:
			#faces.append(f)
			subfaces = results.GetBoundaryFaceInfo(f)
			for sf in subfaces:
				e = linkedDoc.GetElement(sf.SpatialBoundaryElement.HostElementId)
				elements.append(e)
		output.append(elements)
	except:
		output.append(None)	

#Assign your output to the OUT variable.
OUT = output

```

 ![obraz](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/6/8677296585a57259223b54e066562adc2dbfe676.png)

---

<div class="post-metadata">

**Author:** ![newshunhk](https://avatars.discourse-cdn.com/v4/letter/n/3bc359/32.png) [@newshunhk](https://forum.dynamobim.com/u/newshunhk)\
**Post date:** [February 10, 2022, 5:03am UTC](https://forum.dynamobim.com/t/help-needed-to-make-get-spatial-element-boundary-location-work-with-linked-elements/37071/5 "2022-02-10T05:03:30Z")

</div>

I am also looking for how to modify the room.boundary to get the linked document.

---

<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:** [February 10, 2022, 5:15am UTC](https://forum.dynamobim.com/t/help-needed-to-make-get-spatial-element-boundary-location-work-with-linked-elements/37071/6 "2022-02-10T05:15:49Z")

</div>

> [@newshunhk](#):
>
> looking for how to modify the room.boundary to get the linked document

This thread is old and has already solution. Please start new topic with your goals and workflows if you have any. I am going to close 🔒 this topic.

---

<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:** [February 10, 2022, 5:15am UTC](https://forum.dynamobim.com/t/help-needed-to-make-get-spatial-element-boundary-location-work-with-linked-elements/37071/7 "2022-02-10T05:15:53Z")

</div>

Closed on February 10, 2022, 5:15am UTC


