Display the ParameterType of ForgeTypeId

Display the ParameterType of ForgeTypeId

david_rock
Enthusiast Enthusiast
1,777 Views
5 Replies
Message 1 of 6

Display the ParameterType of ForgeTypeId

david_rock
Enthusiast
Enthusiast

Hello,

Sorry I've looked through all the current posts & links on ForgeTypeId and I still don't quite get it.

Previously I had:

MsgBox(objParameter.Definition.ParameterType.ToString)

How can I do the same using GetSpecTypeId GetDataTypeId as ForgeTypeId?

 

Kind Regards

David

0 Likes
1,778 Views
5 Replies
Replies (5)
Message 2 of 6

jeremy_tammik
Alumni
Alumni

Dear David,

 

I do not quite see what you are after. The code snippet should run perfectly well in either case, regardless of whether you are using the old or new conventions. Where is your problem?

 

However, I do see something related in The Building Coder samples. Before the ForgeTypeId, they included a mapping named _map_parameter_type_to_unit_type:

 

https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/P...

 

That was removed to eliminate the deprecated API usage. Maybe you are after something similar using ForgeTypeId instead?

 

Cheers, 

 

Jeremy

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 6

david_rock
Enthusiast
Enthusiast

Hi Jeremy,

Thanks you for your answer, yes, a method (that isn't deprecated) of getting the Parameter Type that can be displayed to a user.  Like the following.

 

ParameterType.png

I've been reading your blog & trying some of the Replacement methods but no luck so far.

https://thebuildingcoder.typepad.com/blog/2020/04/whats-new-in-the-revit-2021-api.html

 

Kind Regards

David

0 Likes
Message 4 of 6

jeremy_tammik
Alumni
Alumni

Looking at the PatameterType enumeration values, I think that I would take a stab at implementing an algorithm to convert them to nice-looking user display strings just by adding a space before each first capital letter followed by a lower case one, e.g., 'LinearForce' --> 'Linear Force', 'HVACDensity' --> 'HVAC Density'. Don't you think that would work? If worst comes to worst, you can implement a text lookup table for exceptional cases.

  

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 5 of 6

RPTHOMAS108
Mentor
Mentor

Is this below not what you are looking for?

 

LabelUtils.GetLabelForSpec(Spec as ForgeTypeId)

or

LabelUtils.GetLabelFor(ParameterType)

 

There is also 

LabelUtils.GetLabelForUnit(Unit as ForgeTypeId)

And for the non-SI  and non metric worlds:

LabelUtils.GetLabelForSymbol(Symbol as ForgeTypeId)

 

In metric world we just say unit symbol for mm is mm, in fact mm is easier to spell than millimetre or millimeter.

 

If they had used the class names:

UnitSpecTypeId, UnitSymbolTypelId, UnitTypeId they all would have been close to one another in an alphabetical list and known to be related to units, easier to compare and understand purposes (forward planning I guess).

 

 

Message 6 of 6

manh.envi
Participant
Participant
Exactly what I am looking for. Thank you.
0 Likes