Get Project parameters of link file python

Hello I got a code that gets the project parameters and their names, it works with current document but it does not work with links instances or documents because I get error:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed. 
Traceback (most recent call last):
  File "<string>", line 28, in <module>
AttributeError: 'NoneType' object has no attribute 'ParameterBindings

the code is this:

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

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

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

inputdoc = UnwrapElement(IN[0])
if inputdoc == None:
	doc = DocumentManager.Instance.CurrentDBDocument
elif inputdoc.GetType().ToString() == "Autodesk.Revit.DB.RevitLinkInstance":
	doc = inputdoc.GetLinkDocument()
elif inputdoc.GetType().ToString() == "Autodesk.Revit.DB.Document":
	doc = inputdoc
else: doc = None

names = []
elems = []

iterator = doc.ParameterBindings.ForwardIterator()
while iterator.MoveNext():
	names.append(iterator.Key.Name)
	elems.append(doc.GetElement(iterator.Key.Id))

OUT = names, elems

How come the linked doc does not have ParameterBindings attribute?

@ruben.romero it is working perfectly from my side, just a side note, why are you getting just the first parameter from your lists? I used the Links node from the Rhythm package as an input:

try using python code to get instance or document input

You appear to be inputting an object which is not returning either Autodesk.Revit.DB.RevitLinInstance or Autodesk.Revit.DB.Document. However without seeing what you are feeding in we can’t really identify where there error is.

1 Like