Thanks @jeremy_tammik
These are always helpful.
My current project requires me to travers all the parameters of various elements from different categories. I can easily get the parameter name, and value.
ParameterData paDa = new ParameterData();
paDa.ParameterName = param.Definition.Name;
switch (param.StorageType)
{
case StorageType.String:
paDa.ParameterValue = param.AsString(); break;
case StorageType.Integer:
paDa.ParameterValue = param.AsInteger().ToString(); break;
case StorageType.Double:
paDa.ParameterValue = param.AsDouble().ToString(); break;
default:
paDa.ParameterValue = param.AsValueString(); break;
}
My next goal is to get the unit type (mm, cm, cm2, ft, ft2, etc.). Since some of the parameters have complex unit types such as w/m2, I can't predict all the unit types to manually code them in. In order to get the UnitTypeID I'm using
ForgeTypeId unitTypeId = param.GetUnitTypeId();
For my application it's important to have the parameter name, parameter value, and parameter unit type as separate fields, so that I may operate / query them individually. The obvious problem is that not every parameter has a Unit Type. So I have to run the line of code above in a try/catch block. Is there a way to identify if the parameter has a Unit Type before trying to execute the line of code above? I have a hunch the application is taking a performance hit since the try / catch block triggers quite often.
Thank you.