Then try this:
you need to watch out for your revit version, it seems you’ve looked into an api-documentation for an older version as in Revit >=2022 there was a change.
To adress this problem you can use something like this to get your code working for older and newer versions of revit:
if int(DocumentManager.Instance.CurrentUIApplication.Application.VersionNumber) < 2021:
factor = UnitUtils.ConvertToInternalUnits(304.8,doc.GetUnits().GetFormatOptions(UnitType.UT_Length).DisplayUnits)
else:
factor = UnitUtils.ConvertToInternalUnits(304.8,doc.GetUnits().GetFormatOptions(SpecTypeId.Length).GetUnitTypeId())