UnitTypeId revit api
public Result TObj64a(Autodesk.Revit.UI.ExternalCommandData commandData,
ref string message, Autodesk.Revit.DB.ElementSet elements)
{
Document Doc = commandData.Application.ActiveUIDocument.Document;
ForgeTypeId UTid = Doc.GetUnits().GetFormatOptions(SpecTypeId.Length).GetUnitTypeId();
ForgeTypeId[] Choices = new ForgeTypeId[] { UnitTypeId.Meters, UnitTypeId.Centimeters, UnitTypeId.Millimeters, UnitTypeId.Feet};
int x = Array.IndexOf(Choices, UTid);
TaskDialog.Show("Units", x.ToString());
return Result.Succeeded;
}