Find distance from Revit.DB.Solid to a point

revit
python
geometry

#1

Hello

I am trying to create an efficient way to find which room or space an element is closest to, while not needing to be inside it.

So far I have gotten the Autodesk.Revit.DB.Solid from my spaces, and insertionpoints from a few lighting fixtures.
I want to somehow see for each point which solid is closest to it, but I do not know how to go about doing this. Any tips or tricks?

I do not want to create solid geometry in dynamo, hopefully this is possible to make this graph viable for projects with 1000 rooms and even more elements.

Here is what I have this far:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)

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

clr.AddReference('DSCoreNodes')
import DSCore
from DSCore.List import *

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

b = []
d = []

OUT = []

for a in IN[0]:
	b.append(UnwrapElement(a))
	
for c in b:
	d.append(c.ClosedShell)

for _ in d:
	for __ in _:
		OUT.append(__)