Spot elevations and elements

is there any way to extract the element a spot elevation is attached to. i can get the spot elevations but i was wondering if this could be a automatic process?
thanks

Hi @jschnare,

It’s not that straight forward, but you can get the “host” (a reference actually) like this:

Python:

import clr

#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

#Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

#Reference the active Document and application
doc = DocumentManager.Instance.CurrentDBDocument

#Start scripting here:
sd = UnwrapElement(IN[0])

elems = []

for i in sd:
	ref = i.References #Get the Spot Dimension reference. Returns a Reference Array
	
	for j in ref:
		elemid = j.ElementId #Iterate the Reference Array and use the ElementId property to get the ids
		elems.append(doc.GetElement(elemid)) #Use the GetElement() method to get the actual elements
		
OUT = elems
1 Like

MAGIC, I WILL TRY TO WORK WITH THIS, THANKS @MartinSpence

It will work for other elements that fall in the same category, ofcause, like Spot Slopes and Spot Coordinates:

By altering the code a little bit, you can get a list of reference elements per Spot Dimension you input. Might become handy if you have Spot Dimensions that references more than one element, like a linear dimension :-):

Python:

import clr

#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

#Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

#Reference the active Document and application
doc = DocumentManager.Instance.CurrentDBDocument

#Start scripting here:
sd = UnwrapElement(IN[0])

elems = []

for i in sd:
	ref = i.References #Get the Spot Dimension reference. Returns a Reference Array
	temp = []
	for j in ref:
		elemid = j.ElementId #Iterate the Reference Array and use the ElementId property to get the ids
		temp.append(doc.GetElement(elemid)) #Use the GetElement() method to get the actual elements
	elems.append(temp)	
	
OUT = elems
6 Likes

@MartinSpence THIS WORKED PERFECTLY, I CANT THANK YOU ENOUGH! MY COMPANY IS PLANNING ON INVESTING IN PYTHON TRAINING FOR THIS REASON.
THANKS

Cool! :slight_smile:

Glad I could help :blush: