How to get the Family and Type parameter value of Revit linked elements with python

it gets null as well for every Revit element in a revit link if using getparametervaluebyname “Family and Type” , I am wondering if that function to get parameter value does not work for linked elements. I tried myself with OOTB dynamo nodes and does not work directly, what I was able to do is to get Element.Parameters, convert them to string and search only the results of parameters of elements that contain or start by string "Family and Type : ", so i take the value string and remove the part "Family and Type : " from it so I get the clean string value, but this looks very excessive silly processing I am sure must be a more direct way to get the parameter value from revit linked elements?

try clockwork element.type node

@rrvivancosWTL pretty much looks like this, nearly identical to how you would do it in a local model. You just need to GetLinkDocument()

doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

links = FilteredElementCollector(doc).OfClass(RevitLinkInstance).ToElements()

first_link_doc = links[0].GetLinkDocument()
elems = FilteredElementCollector(first_link_doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().ToElements()
     
OUT = elems[0].LookupParameter("Family and Type").AsValueString()

1 Like

yeah easy thanks.

I tried also this different solutions:

param = e.get_Parameter(BuiltInParameter.ELEM_FAMILY_AND_TYPE_PARAM)
if param and param.HasValue:
    identification_name = param.AsValueString()  # Use AsValueString() instead of AsString()
else:
    identification_name = None

also this:

# Identification_Name by scanning parameters
identification_name = None
param_prefix = "Family and Type : "

# Loop through all parameters of the element
# Note: For linked elements, 'e' is still a Revit element from the linked doc.
for p in e.Parameters:
    # Try to get a parameter value as string
    val = None
    if p.StorageType == StorageType.String:
        val = p.AsString()
    if val is None: # If not a string param, try AsValueString
        val = p.AsValueString()
    
    # If we got a value and it starts with "Family and Type : "
    if val and val.startswith(param_prefix):
        # Extract the substring after "Family and Type : "
        identification_name = val[len(param_prefix):].strip()
        break