Hello,
Seeking assistance to export family parameters from a library to an Excel file. Retrieved names, but values return memory addresses. Grateful for any help.
Thank you kindly.
import clr
# Add references
clr.AddReference("RevitServices")
clr.AddReference("RevitAPI")
# Import necessary modules
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
import Autodesk
from Autodesk.Revit.DB import *
# Helper function to convert input to a list of elements
def unwrap_list(input):
return input if isinstance(input, list) else [input]
# Preparing input from Dynamo to Revit
famDocs = UnwrapElement(IN[0])
famNames = [f.Title for f in famDocs]
# Get all the data we need to check vs excel
famTypesList, famTypeNamesList, famParamsList, famParamNamesList = [], [], [], []
for f in famDocs:
# Get family name and manager
famMan = f.FamilyManager
# Get type data
famTypes = list(famMan.Types)
typeNames = [f.Name for f in famTypes]
famTypesList.append(famTypes)
famTypeNamesList.append(typeNames)
# Get parameters
params = famMan.GetParameters()
paramNames = [p.Definition.Name for p in params]
famParamsList.append(params)
famParamNamesList.append(paramNames)
# Function to get parameter values for each family type and parameter
def get_family_param_values(fam_params, fam_types_list):
param_values_list = []
for params in fam_params:
param_values = []
for t in fam_types_list:
for param in params:
param_value = str(param) # Use str() for all parameter types
#a = ctypes.cast(param_value,ctypes.py_object).value
param_values.append(param_value)
param_values_list.append(param_values)
return param_values_list
# Process the output to display the parameter values
output = []
for i, param_values in enumerate(get_family_param_values(famParamsList, famTypesList)):
fam_name = famNames[i]
fam_type_names = famTypeNamesList[i]
param_names = famParamNamesList[i]
data = {
'Family Name': fam_name,
'Family Types': fam_type_names,
}
for j, param_name in enumerate(param_names):
data[param_name] = param_values[j]
output.append(data)
# Preparing output to Dynamo
OUT = output