basically I want to extract the discipline from the shared parameter property from the txt file of shared parameters.
I thought it could be like: UnitType Property is until Revit 2020 but in revit 2021 is updated to GetUnitTypeId(), although any of those are available beyond revit 2021?
essentially I want to get the properties of shared parameters in the txt external file of shared parameters, they are not used yet in the project or family editor, not added as project/family parameters.
I tried this suggestion based in the link provided
//tmpParam is a Family Parameter
string getDateTypeId = tmpParam.Definition.GetDataType().TypeId;
string Discipline = getDateTypeId.Split(':')[0].Split('.').Last();
string TypeOfParameter = getDateTypeId.Split(':')[1].Split('-')[0];
but a shared parameter from a txt file does not have this property I believe, I do not have results for this, essentially I want to get the properties of shared parameters in the txt external file of shared parameters, they are not used yet in the project or family editor, not added as project/family parameters.
Can you path to the shared parameter file and read the part of the .txt. you need? they have a constant structure?
It appears to be an integer which relates to this enumeration?
Updated to…
But still, 1 appears to represent Architecture?
*PARAM GUID NAME DATATYPE DATACATEGORY GROUP VISIBLE DESCRIPTION USERMODIFIABLE HIDEWHENNOVALUE
PARAM 62792403-ad7f-40a0-b10f-01adc8e38abc OBE_Project_UValue_Walls TEXT **1** 1 The thermal performance for walls (W/m2K) 1 0
is there any way to get this done compatible for any Revit version from 2019 to 2023?
I am getting this error in Revit 2019 for example:
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File "<string>", line 26, in <module>
AttributeError: 'ExternalDefinition' object has no attribute 'GetDataType'
I tried something like that but the results read like: UT_Custom,UT_Number, UT_Length, but I was asking the Discipline instead not that
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from System.Collections.Generic import Dictionary
import System
# Get the current document and application instances
doc = DocumentManager.Instance.CurrentDBDocument
app = doc.Application
# Open the shared parameters file
spfile = app.OpenSharedParameterFile()
# Initialize a list to collect dictionaries of parameter details
paramDetails = []
if spfile: # Check if the shared parameters file is not None
for group in spfile.Groups:
groupName = group.Name # Get the name of the group
for definition in group.Definitions:
# Ensure we're working with ExternalDefinition to access specific properties
if isinstance(definition, ExternalDefinition):
details = Dictionary[str, object]()
# Check for UnitType in API versions prior to Revit 2021
if hasattr(definition, "UnitType"): # Older API versions
details.Add("UnitType", definition.UnitType.ToString())
# For Revit 2021 and later, use GetUnitTypeId
elif hasattr(definition, "GetUnitTypeId"): # Revit 2021+
unitTypeId = definition.GetUnitTypeId()
# Use the LabelUtils to get a more readable string
unitTypeString = LabelUtils.GetLabelFor(unitTypeId)
details.Add("UnitType", unitTypeString)
paramDetails.append(details)
# Preparing output to Dynamo
OUT = paramDetails
hello, I really appreciate the answers which are awesome. I tried in Revit 2019 and get this error:
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File "<string>", line 36, in <module>
Exception: unitType is an invalid unit type. See UnitUtils.IsValidUnitType() and UnitUtils.GetValidUnitTypes().
Parameter name: unitType
Discipline is not something that exists in the shared parameters txt file, but we could understand that if parameter type is length that means its discipline is under “Common”, I did not imagine something so simple like this can cause trouble.