How to change the units of a family used in the model

Dear all,
i am trying to update my family Units used in my Revit model is there any way if we can batch all families unit pls find the attached script below and suggest me if we need to add anything.

are you try this ?

Note :
it is better to copy-paste your code in your post