Retrieve instance parameter value from linked element

I’d like to retrieve the level information from structural framing elements of a linked file. This is what I have for now:

import System
import sys
import clr

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

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

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

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

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

elements = UnwrapElement(IN[0])

for el in elements:
	el_parameter = el.LookupParameter("Reference Level")
	level = el_parameter.AsString()

		
OUT = level

I have retrieved the linked elements from another script. Right now the output is “null”.

Level is stored as an element, so you would get the string by using AsValueString(). AsString() would be for a parameter value that’s already stored as a string.

Also, you currently loop through each element but overwrite the level value each time. You need a list that you can append each value to so that you can return the whole list.

1 Like