Reference Plane - Is Reference

I’m trying to get the Is Reference parameter for reference planes in a family, and I can get it using Element.GetParameterValueByName but it returns a bunch of numbers, rather than Strong Reference, Weak Reference, etc. Is there someplace that documents how the numbers translate into an actual name, or a way to extract it through Dynamo? I looked through RevitAPIDocs but didn’t find anything that specified the translation.

Thanks :beers:


ReferencePlaneIsReference.dyn (3.3 KB)

That’s a good question. Usually the API will state what the indexes refer to (in the case of enums for built-in parameters its always an index). The other trick is to follow an iterative integer assignment to match each member of the drop-down list you see in Revit, in-order. The quickest option then was a simple trial-and-error python script to check instead. Here are the wonderfully counter-intuitive results:

e = UnwrapElement(IN[0])

TransactionManager.Instance.EnsureInTransaction(doc)

param = e.ParametersMap["Is Reference"]

list = []
for i in range(20):
	try:
		param.Set(i)
		list.append(param.AsValueString())
	except:
		break

TransactionManager.Instance.TransactionTaskDone()

OUT = list
1 Like

Cool! The stupid question on my part now, is what are the blanks in the list?

edit: would you also mind posting the rest of the Python? I’m ever so slowly trying to figure it out but I’m not quite there yet and keep getting errors when I try to use the snippet you posted :persevere:

Here’s what I thought would work, based on my fumbling around earlier:

edit2: probably should buy a book or subscription to a learning site…

Sure:

# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)

# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)

# Import DocumentManager and TransactionManager
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 *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

e = UnwrapElement(IN[0])

TransactionManager.Instance.EnsureInTransaction(doc)

param = e.ParametersMap["Is Reference"]

list = []
for i in range(20):
	try:
		param.Set(i)
		list.append(param.AsValueString())
	except:
		break

TransactionManager.Instance.TransactionTaskDone()

OUT = list

The number in the range was just any number large enough to cover members in the Is Reference list in Revit, but was useful in the test given that the list is not ordered by count. I suspect the empty strings (they are null parameter values) are probably plane references reserved for other uses in Revit which are not applicable to families, and are therefore not accessible even via the API. That’s an educated guess though, so it might be worth posting your question on the Revit API forum and getting an answer from the tech team at Autodesk.

Thanks! :beers:

One more dumb question - when i copy that in I’m getting an error related to the line: param = e.ParametersMap[“Is Reference”] and can’t figure out what is causing it. I’ve tried in in a Python node and using the Script from String and get the same error in both.