ParameterType and BuiltInParameterGroup enums are obsolete in recent Revit versions

ParameterType and BuiltInParameterGroup enums are obsolete in recent Revit versions

mizrachi_amir2
Advocate Advocate
629 Views
2 Replies
Message 1 of 3

ParameterType and BuiltInParameterGroup enums are obsolete in recent Revit versions

mizrachi_amir2
Advocate
Advocate

Hello,

I have a chunck of code to create a project parameter based on this Dynamo node.

But now I noticed that the below code snippet won't work on Revit API 2022 and above:

var parameterType = ParameterType.Text;
if (!System.Enum.TryParse(type, out parameterType))
    throw new System.Exception("Parameter not found");

// parse parameter group
var parameterGroup = BuiltInParameterGroup.PG_DATA;
if (!System.Enum.TryParse(group, out parameterGroup))
    throw new System.Exception("Parameter not found");

 

If I move to Revit 2022/2023 API I get this warning/error respectively:

'ParameterType' is obsolete: 'This enumeration is deprecated in Revit 2022 and may be removed in a future version of Revit. Please use the `ForgeTypeId` class instead. Use properties of the `SpecTypeId` class and its nested classes to replace uses of specific values of this enumeration.'	

 

And if I move to Revit 2024/2025 API I get this warning/error respectively:

'BuiltInParameterGroup' is obsolete: 'This enumeration is deprecated in Revit 2024 and may be removed in a future version of Revit. Please use members of the `GroupTypeId` class instead.'	

 

I tried to use ChatGPT and other methods on the web to resolve these issues but to no avail so far. Tried to use SpecTypeId and GroupTypeId but nothing is working for me.

 

Can someone please assist?

0 Likes
630 Views
2 Replies
Replies (2)
Message 2 of 3

Speed_CAD
Collaborator
Collaborator

Hi,

 

Try using this:

ForgeTypeId parameterTypeId = SpecTypeId.String.Text;
ForgeTypeId groupTypeId = GroupTypeId.Data;

 

I don't know how you are going to use the variables but here I give you an example:

ExternalDefinitionCreationOptions exOptions = new ExternalDefinitionCreationOptions("name", parameterTypeId);
ExternalDefinition exDefinition = definitionGroup.Definitions.Create(exOptions) as ExternalDefinition;
...
...
document.ParameterBindings.Insert(exDefinition, binding, groupTypeId);

 

Mauricio Jorquera
Message 3 of 3

mizrachi_amir2
Advocate
Advocate

Thank you, @Speed_CAD
Actually, I tried using "GroupTypeId.Data" and "SpecTypeId.String.Text" but now I figured out that I had to solve my enum issue as follows:
For instance, for versions up to 2021:

 var parameterType = ParameterType.Text;
 if (!System.Enum.TryParse(type, out parameterType))
     throw new Exception("Parameter not found: " + type);

 

While for versions 2022 and up:

Dictionary<string, ForgeTypeId> parameterTypeMap = new Dictionary<string, ForgeTypeId>()
{
    { "Text", SpecTypeId.String.Text },
};

if (!parameterTypeMap.TryGetValue(type, out ForgeTypeId parameterType))
    throw new Exception("Parameter not found: " + type);

 

 Now it is working correct in all versions.

Thanks for your help 🙂

0 Likes