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

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 im not sure how to use that in such a way to get those bounding elements, from what i skimmed in the RevitApiDocs i cant 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?

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.

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.

import clr
from Autodesk.Revit.DB import *
import Autodesk

import Revit

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

# Import 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 = []
    	results = calculator.CalculateSpatialElementGeometry(item)
	for face in results.GetGeometry().Faces:
		for bface in results.GetBoundaryFaceInfo(face):
			if bface.GetBoundingElementFace().MaterialElementId.IntegerValue == -1:


OUT = faceelements

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

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:
		results = calculator.CalculateSpatialElementGeometry(r)
		solid = results.GetGeometry()
		elements = []
		for f in solid.Faces:
			subfaces = results.GetBoundaryFaceInfo(f)
			for sf in subfaces:
				e = linkedDoc.GetElement(sf.SpatialBoundaryElement.HostElementId)

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